Resection has been commonly utilized for treating huge hepatocellular carcinoma (HCC) with a diameter of ≥10 cm; however, a high rate of mortality is reported due to recurrence. The present study was designed to predict the recurrence following resection based on preoperative and postoperative machine learning models. In total, 1,082 patients with HCC who underwent liver resection in the Eastern Hepatobiliary Surgery Hospital cohort between January 2008 and December 2016 were divided into a training cohort and an internal validation cohort. In addition, 164 patients from Mengchao Hepatobiliary Hospital cohort between January 2014 and December 2016 served as an external validation cohort. The demographic information, and serological, MRI, and pathological data were obtained from each patient prior to and following surgery, followed by evaluating the model performance using the concordance index, time-dependent receiver operating characteristic curves, prediction error cures, and a calibration curve. A preoperative random survival forest (RSF) model and a postoperative RSF model were constructed based on the training set, which outperformed the conventional models, such as the Barcelona Clinic Liver Cancer (BCLC), the 8th edition of the American Joint Committee on Cancer (AJCC 8th) staging systems, and the Chinese stage systems. In addition, the preoperative and postoperative RSF models could also re-stratify patients with BCLC stage A/B/C or AJCC 8th stage IB/II/ⅢA/ⅢB or Chinese stage IB/IIA/ⅡB/ⅢA into low-risk, intermediate-risk, and high-risk groups in the training and the two validation cohorts. The preoperative and postoperative RSF models were effective for predicting recurrence in patients with huge HCC following hepatectomy.