Objective To establish a pain prediction model for patients with gynecological malignant tumor during postoperative anesthesia recovery, and to evaluate prediction performance of the model. Methods A total of 342 patients undergoing gynecological malignant tumor resection were selected as the research subjects by employing the convenience sampling. The risk factors for pain during postoperative anesthesia recovery were screened by using the univariate analysis and Pearson correlation analysis. Then the data were randomly divided into the training set and the test set according to the ratio of 7∶3. Based on the data from the training set, the random forest algorithm was adopted to establish pain risk prediction model during postoperative anesthesia recovery, and then prediction linear fit charts of the training and test sets were drawn. The importance of risk factors was ranked. The influence of different risk factors for the occurrence risk of pain was analyzed. Results All patients had different degrees of postoperative anesthesia recovery pain. Pain score of the training set was 3.85±1.12, and pain score of the test set was 3.79±1.08. The random forest model established based on the training set revealed that intraoperative lymph node dissection, doses of opioids used, International Federation of Gynecology and Obstetrics (FIGO) staging and age were the main prediction factors for postoperative anesthesia recovery pain. The results of data validation based on the test set interpreted that the model exerted favorable performance in the aspects of prediction accuracy and robustness. Conclusion Intraoperative lymph node dissection, doses of opioids used, FIGO staging and age are the main prediction factors for postoperative anesthesia recovery pain in patients with gynecological malignant tumor, and the prediction model established based on the random forest algorithm exerts favorable prediction performance.