One of the crucial research areas in agricultural decision-making processes is crop yield prediction. This study leverages the advantages of hybrid models to address the complex interplay of genetic, environmental, and management factors to achieve more accurate crop yield forecasts. Therefore, this study used the data of wheat growth environment, crop management, and historical yield in experimental fields in Anding District, Dingxi City, Gansu Province from 1984 to 2021 to construct eight machine learning models and ensemble models. Furthermore, Agricultural Production Systems sIMulator (APSIM), machine learning (ML), and APSIM combined with machine learning (APSIM-ML) were employed to predict wheat yields in 2012, 2016, and 2021. The results show that the APSIM-ML weighted ensemble prediction model, optimized to minimize the MSE, performed the best. Compared to the optimized ML and APSIM models, the average improvements in the RMSE, RRMSE, and MBE for the test years were 43.54 kg/ha, 3.55%, and 15.54 kg/ha, and 93.96 kg/ha, 7.55%, and 104.21 kg/ha, respectively. At the same time, we found that the dynamic flow of water and nitrogen between the soil and crops had the greatest impact on wheat yield prediction. This study improved the accuracy of dryland wheat yield prediction in Gansu Province and provides technical support for the intelligent production of dryland wheat in the loess hilly area.