ABSTRACTWastewater land application is a widely accepted solution for addressing global water crisis, particularly in arid and semiarid regions, but it may cause soil Ca, Mg, and Na accumulation and result in soil degradation. The objective of this study was to investigate the underlying mechanisms impacting soil Ca, Mg, and Na in wastewater land application systems using tree‐based machine learning models. Using data collected from previous field studies, decision tree (DT), random forest (RF), and extreme gradient boosting decision trees (XGBoost) models were developed to predict soil Ca, Mg, and Na in wastewater land application systems. XGBoost models showed the best performance, with R2 and RMSE values of 0.999 and 18.9 mg/kg, 0.999 and 3.2 mg/kg, and 0.912 and 104 mg/kg on the training data and 0.989 and 345 mg/kg, 0.925 and 56.1 mg/kg, and 0.908 and 112 mg/kg on the test data for soil Ca, Mg, and Na prediction, respectively. Permutation importance analysis reveals that initial soil Ca and electrical conductivity (EC) and total irrigation amount, initial soil Mg, total precipitation and initial soil EC, and initial soil Na, total irrigation amount and wastewater Na were the top three predictive variables for soil Ca, Mg, and Na, respectively. Partial dependence analysis demonstrates how soil Ca, Mg, and Na changed with the predictive variables, and indicates that wastewater irrigation caused soil Ca, Mg, and Na accumulation. This study highlights the need for sustainable wastewater land application management to control soil sodium adsorption ratio and mitigate the risks of land degradation.