Heavy metal pollution in agricultural land poses significant threats to both the ecological environment and human health. Therefore, the rapid and accurate prediction of heavy metal content in agricultural soil is crucial for environmental protection and soil remediation. Acknowledging the limitations of traditional single linear or nonlinear machine learning models in terms of prediction accuracy, this study developed an ensemble learning model that integrates multiple linear or nonlinear learning models with a random forest (RF) model to improve both the prediction accuracy and reliability. In this study, we selected a typical copper (Cu) polluted area in the Pearl River Delta of Guangdong Province as the research site and collected Cu content data and indoor soil reflectance spectral data from 269 surface soil samples. First, the soil spectral data were preprocessed using Savitzky–Golay (SG) smoothing, multiplicative scattering correction (MSC), and continuous wavelet transform (CWT) to reduce noise interference. Next, principal components analysis (PCA) was employed to reduce the dimensionality of the preprocessed spectral data, eliminating redundant features and lowering the computational complexity. Finally, based on the dimensionality-reduced data and Cu content, we established a stacked ensemble learning model, where the base models included SVR, PLSR, BPNN, and XGBoost, with RF serving as the meta-model to estimate the soil heavy metal content. To evaluate the performance of the stacking model, we compared its prediction accuracy with that of individual models. The results indicate that, compared to the traditional machine learning models, the prediction accuracy of the stacking model was superior (R2 = 0.77; RMSE = 7.65 mg/kg; RPD = 2.29). This suggests that the integrated algorithm demonstrates a greater robustness and generalization capability. This study presents a method to improve soil heavy metal content estimation using hyperspectral technology, ensuring a robust model that supports policymakers in making informed decisions about land use, agriculture, and environmental protection.