Studying the spatiotemporal variation and driving mechanisms of vegetation net primary productivity(NPP) in the Guanzhong Plain Urban Agglomeration(GPUA) of China is highly important for regional green and low-carbon development. This study used the Theil-Sen trend analysis, Mann-Kendall trend test, coefficient of variation, Hurst index, and machine learning method(eXtreme Gradient Boosting and SHapley Additive exPlanations(XGBoost-SHAP)) to analyze the spatiotemporal variation of NPP in the GPUA from 2001 to 2020 and reveal its response to climate change and human activities. The results found that during 2001–2020, the averageNPP in the GPUA showed a significant upward trend, with an annual growth rate of 10.84 g C/(m2·a). The multi-year averageNPP in the GPUA was 484.83 g C/(m2·a), with higher values in the southwestern Qinling Mountains and lower values in the central and northeastern cropland and built-up areas. The average coefficient of variation of NPP in the GPUA was 0.14, indicating a relatively stable state overall, but 72.72% of the study area showed weak anti-persistence, suggesting that NPP in most areas may have declined in the short term. According to XGBoost-SHAP analyses, elevation, land use type and precipitation were identified as the main driving factors of NPP. Appropriate precipitation and higher temperatures promote NPP growth, whereas extreme climates, high population density, and nighttime lighting inhibit NPP. This study has important theoretical and practical significance for achieving regional sustainable development, offers a scientific basis for formulating effective ecological protection and restoration strategies, and promotes green, coordinated, and sustainable development in the GPUA.