Background: Anastomotic leakage (AL) is one of the commonest and most serious complications after rectal cancer surgery. The previous analyses on predictors for AL included small-scale patients, and their prediction models performed unsatisfactorily.Methods: Clinical data of 5,220 patients who underwent anterior resection for rectal cancer were scrutinized to create a prediction model via random forest classifier. Additionally, data of 836 patients served as the test dataset. Patients diagnosed with AL within 6 months' follow-up were recorded. A total of 20 candidate factors were included. Receiver operating characteristic (ROC) curve was conducted to determine the clinical efficacy of our model, and compare the predictive performance of different models.Results: The incidence of AL was 6.2% (326/5,220). A multivariate logistic regression analysis and the random forest classifier indicated that sex, distance of tumor from the anal verge, bowel stenosis or obstruction, preoperative hemoglobin, surgeon volume, diabetes, neoadjuvant chemoradiotherapy, and surgical approach were significantly associated with AL. After propensity score matching, the temporary stoma was not identified as a protective factor for AL (P=0.58). Contrastingly, the first year of performing laparoscopic surgery was a predictor (P=0.009). We created a predictive random forest classifier based on the above predictors that demonstrated satisfactory prediction efficacy. The area under the curve (AUC) showed that the random forest had higher efficiency (AUC =0.87) than the nomogram (AUC =0.724).Conclusions: Our findings suggest that eight factors may affect the incidence of AL. Our random forest classifier is an innovative and practical model to effectively predict AL, and could provide rational advice on whether to perform a temporary stoma, which might reduce the rate of stoma and avoid the ensuing complications.