Background: Postoperative delirium is a common complication that is distressing. This study aimed to demonstrate a prediction model for delirium. Methods: Among 203,374undergoing non-cardiac surgery between January 2011 and June 2019 at Samsung Medical Center, 2,865 (1.4%) were diagnosed with postoperative delirium. After comparing performances of machine learning algorithms, we chose variables for a prediction model based on an extreme gradient boosting algorithm. Using the top five variables, we generated a prediction model for delirium and conducted an external validation. The Kaplan–Meier and Cox survival analyses were used to analyse the difference of delirium occurrence in patients classified as a prediction model. Results: The top five variables selected for the postoperative delirium prediction model were age, operation duration, physical status classification, male sex, and surgical risk. An optimal probability threshold in this model was estimated to be 0.02. The area under the receiver operating characteristic (AUROC) curve was 0.870 with a 95% confidence interval of 0.855–0.885, and the sensitivity and specificity of the model were 0.76 and 0.84, respectively. In an external validation, the AUROC was 0.867 (0.845–0.877). In the survival analysis, delirium occurred more frequently in the group of patients predicted as delirium using an internal validation dataset (p < 0.001). Conclusion: Based on machine learning techniques, we analyzed a prediction model of delirium in patients who underwent non-cardiac surgery. Screening for delirium based on the prediction model could improve postoperative care. The working model is provided online and is available for further verification among other populations. Trial registration: KCT 0006363.