Soil salinization is closely related to land degradation, and it is supposed to exert a significant negative effect on soil organic carbon (SOC) stock dynamics. This effect and its mechanism have been examined at site and transect scales in previous studies while over a large spatial extent, the salinity-induced changes in SOC stock over space and time have been less quantified, especially by machine learning and remote sensing techniques. The main focus of this study is to answer the following question: to what extent can soil salinity exert an additional effect on SOC stock over time at a larger spatial scale? Thus, we employed the extreme gradient boosting models (XGBoost) combined with field site-level measurements from 433 sites and 41 static and time-varying environmental covariates to construct methods capable of quantifying the salinity-induced SOC changes in a typical inland river basin of China between the 1990s and 2020s. Results showed that the XGBoost models performed well in predicting the soil electrical conductivity (EC) and SOC stock at 0–20 cm, with the R2 value reaching 0.85 and 0.81, respectively. SOC stock was found to vary significantly with increasing soil salinity following an exponential decay function (R2 = 0.27), and salinity sensitivity analysis showed that soils in oasis were expected to experience the largest carbon loss (−137.78 g m−2), which was about 4.84, 14.37, and 25.95 times higher than that in the saline, bare, and sandy land, respectively, if the soil salinity increased by 100%. In addition, the decrease in the soil salinity (−0.32 dS m−1) from the 1990s to the 2020s was estimated to enhance the SOC stock by 0.015 kg m−2, which contributed an additional 10% increase to the total SOC stock enhancement. Overall, the proposed methods can be applied for quantification of the direction and size of the salinity effect on SOC stock changes in other salt-affected regions. Our results also suggest that the role of soil salinization should not be neglected in SOC changes projection, and soil salinization control measures should be further taken into practice to enhance soil carbon sequestration in arid inland river basins.