Estimating the spatial distribution of soil organic carbon (SOC) content is essential for evaluating ecosystem functions and establishing global climate change models. Most of the previous SOC mapping studies have focused on estimating SOC content at fixed depths. However, soils at the same depth are not always belonging to the same soil horizon. Therefore, the characteristics of soil horizons should be considered. In this study, the SOC content of multiple soil horizons in the middle and upper reaches of the Heihe River Basin was estimated using multivariate factors and ensemble learning (EL). The results show that EL obtains the best SOC content estimation performance, where the R2 values are 0.58, 0.57 and 0.69 for the O-horizon, A-horizon, and B-horizon, respectively. Environmental factors show a high degree of contribution to estimate SOC content, and mean annual precipitation (MAP) presents the highest contribution amongst all the factors. For the middle and upper reaches of the Heihe River Basin, the SOC content is high in the southwest and low in the northeast. Amongst the multiple soil horizons, the O-horizon usually showed higher SOC content than the A-horizon and the B-horizon. But the SOC content of the A-horizon is higher than that of the O-horizon for farmland. From 2012 to 2013, the SOC content of forestland and farmland increased in the O-horizon and A-horizon. The application of EL improves the mapping performance of SOC content in different soil horizons, and the involvement of multivariable factors reveals the distribution of SOC content in the Heihe River Basin. This study creates maps of SOC content in different soil horizons and analyses the effect of land covers on SOC content, which provides insights for ecological conservation and regional sustainable development.