Net primary productivity (NPP) has been substantially changed under the intense oasification in the urban agglomerations on the northern slopes of mid-Tianshan Mountain (UANSTM) and climate change. However, the temporal variations of NPP under the oasification remain unclear, and the relative contribution of oasification and climate change on annual NPP variation is still under debate. By using remote sensing data, reanalysis data, modified Carnegie–Ames-Stanford Approach (CASA) model, and a machine learning method, we explored the spatial–temporal variation of NPP in the UANSTM region and quantified the contribution of oasification and climate change to NPP variation from 2001 to 2020. Our study indicated that: (1) the NPP presents an overall increasing trend in the most of region and the region presented decreasing trend mainly due to the cropland conversion to the urban area; (2) the oasification-dominated NPP area concentrated in the built-up land and cropland; (3) during 2001–2020, the NPP increased by about 5.4 Tg·C, and the contribution of climatic and oasification to NPP increase were quantified (73.1% and 26.9%, respectively); (4) water-related factors was the main driver of NPP variation in the UANSTM region.