Exposure to greenness may lead to a wide range of beneficial health outcomes. However, the effects of greenness on preterm birth (PTB) are inconsistent, and limited studies have focused on the subcategories of PTB. A total of 3,751,672 singleton births from a national birth cohort in mainland China were included in this study. Greenness was estimated using the satellite-based Normalized Difference Vegetation Index (NDVI) and Enhanced Vegetation Index with 500-m and 1,000-m buffers around participants’ addresses. The subcategories of PTB (20–36 weeks) included extremely PTB (EPTB, 20–27 weeks), very PTB (VPTB, 28–31 week), and moderate-to-late PTB (MPTB, 32–36 weeks). Gestational age (GA) was included as another birth outcome. We used logistic regression models and multiple linear regression models to analyze these associations throughout the entire pregnancy. We found inverse associations between greenness and PTB and positive associations between greenness and GA. Specifically, an increase of 0.1 NDVI exposure within a 500-m buffer throughout the entire pregnancy was significantly associated with decreases in PTB (odds ratio [OR], 0.930; 95% confidence interval [CI], 0.927–0.932), EPTB (OR, 0.820; 95% CI, 0.801–0.839), VPTB (OR, 0.913; 95% CI, 0.908–0.919), MPTB (OR, 0.934; 95% CI, 0.931–0.936), and an increase in GA (β = 0.050; 95% CI, 0.049–0.051 weeks). These results suggest the potential protective effects of greenness on PTB and its subcategories: MPTB, VPTB, and EPTB in China.