Net primary production (NPP) serves as a crucial indicator of the ecosystem’s capacity to capture atmospheric CO2. Gaining insights into the dynamics of NPP and its driving mechanisms is pivotal for optimizing ecosystem carbon sink resource management. Since the implementation of the Grain-for-Green Program (GFGP) in 1999, the Yellow River Basin (YRB) has been one of the most significant areas for ecological restoration in China. However, our knowledge regarding the interannual variability (IAV) of NPP and the underlying driving forces in this region remains incomplete. In this study, we utilized a light use efficiency model to assess the spatiotemporal dynamics, IAV, and driving factors of NPP in the YRB during the period from 1999 to 2018. Our findings revealed that the average annual NPP in the YRB approximated 189.81 Tg C. Over the study duration, NPP significantly increased in 79.63% of the basin with an overall increasing rate of 6.76 g C m−2 yr−1. The most prominent increase was observed in the key GFGP implementation area, predominantly in the semi-humid region. Notably, the middle altitude region (1–1.5 km), semi-humid region, and grassland emerged as the primary contributors to the basin’s total vegetation carbon sequestration. However, it is worth emphasizing that there was substantial IAV in the temporal trends of NPP, with the semi-humid region being the most influential contributor (62.66%) to the overall NPP IAV in the YRB. Further analysis of the driving mechanisms unveiled precipitation as the primary driver of NPP IAV in the YRB with a contribution of 62.9%, followed by temperature (23.07%) and radiation (14.03%). Overall, this study deepened our understanding of the IAV and driving mechanisms of NPP in the YRB under ecological restoration, and provided scientific support for optimizing the management of regional carbon sequestration resources.