Soil organic carbon (SOC) is a crucial component of the terrestrial carbon cycle and essential for agricultural productivity. Quantifying its sensitivity to future climate change is vital for sustaining agricultural practices and mitigating greenhouse gas emissions. However, this remains a challenge as long-term SOC data are scarce and substantial uncertainties regarding future climate scenarios. This study presents a bottom-up machine learning framework to assess the spatiotemporal variations of SOC and its vulnerability to climate change in the Jinghe River Basin, a typical loess hilly and gully watershed. Firstly, the long-term (2000-2023) dynamics of SOC was estimated by integrating in-situ measurements with machine learning techniques. Results show that the high SOC values are primarily distributed in the farmland of the mountain-loess transition zone, while the low-value areas are mainly found in the loess region. During the study period, the SOC content exhibited a slight increasing trend with a rate of 0.02 g kg⁻1 yr⁻1 (p = 0.449). The vulnerability of farmland surface SOC to future climate change was then evaluated by combining a robust machine learning model with the bottom-up framework. To this end, the study explored a wide range of possible future climates to identify critical climate thresholds and their spatial variation across the basin’s farmlands. Based on this analysis, this research found that the farmland in the northern basin is generally more susceptible to changing climate with even marginal rises in temperature could lead to severe loss in SOC. These results highlight the need for proactive climate adaptation strategies to safeguard SOC in vulnerable agricultural landscapes, ensuring soil health and resilience in the face of climate change.