Understanding habitat quality patterns and their drivers in arid zones is of fundamental importance to the sustainability maintenance of terrestrial ecosystems, but remains elusive. Here, we applied the InVEST model to investigate the spatiotemporal patterns of habitat quality in the northern sand-prevention belt (NSPB) across five time periods (2000, 2005, 2010, 2015, 2018), coupled with the structural equation model (SEM) and boosted regression tree (BRT) model to identify their integrated driving forces. The results exhibited that habitat quality in high-level zones expanded gradually from 2000 to 2018, while the middle- and low-level zones shrank. Climate, soil, topography, and human activities were significantly correlated with habitat quality, with mean annual temperature (MAT) and human activities being key contributing factors in the high-level and low-level zones, respectively, whereas the contribution of factors varied considerably in the middle-level zones. The interactions among climate, soil, topography, and human activities jointly drive habitat quality changes. Climate intensified the positive effects of soil on habitat quality, while the topographic and human activities mainly affected habitat quality indirectly through climate and soil. Our findings offer a scientific guidance for the restoration and sustainable management of desertification ecosystems in northern China.