Background School neighborhood food environment is recognized as an important contributor to childhood obesity; however, large-scale and longitudinal studies remain limited. This study aimed to examine this association and its variation across gender and urbanicity at multiple geographic scales. Methods We used the US nationally representative Early Childhood Longitudinal Study–Kindergarten cohort data and included 7530 kindergarteners followed up from 1998 to 2007. The Census, road network, and Dun and Bradstreet commercial datasets were used to construct time-varying measurements of 11 types of food outlet within 800-m straight-line and road-network buffer zones of schools and school ZIP codes, including supermarket, convenience store, full-service restaurant, fast-food restaurant, retail bakery, dairy product store, health/dietetic food store, candy store, fruit/vegetable market, meat/fish market, and beverage store. Two-level mixed-effect and cluster-robust logistic regression models were performed to examine the association. Results A higher body mass index (BMI) in 2007 was observed among children experiencing an increase of convenience stores in school neighborhoods during 1998–2007 (β = 0.39, p < 0.05), especially among girls (β = 0.50) and urban schoolchildren (β = 0.41), as well as among children with a decrease of dairy product stores (β = 0.39, p < 0.05), especially among boys (β = 1.86) and urban schoolchildren (β = 0.92). The higher obesity risk was associated with the increase of fast-food restaurants in urban schoolchildren (OR = 1.27 [95% CI = 1.02–1.59]) and of convenience stores in girls (OR = 1.41 [95% CI = 1.09–1.82]) and non-urban schoolchildren (OR = 1.60 [95% CI = 1.10–2.33]). The increase of full-service restaurants was related to lower obesity risk in boys (OR = 0.74 [95% CI = 0.57–0.95]). The decrease of dairy product stores was associated with the higher obesity risk (OR = 1.68 [95% CI = 1.07–2.65]), especially boys (OR = 2.92 [95% CI = 1.58–5.40]) and urban schoolchildren (OR = 1.67 [95% CI = 1.07–2.61]). The schoolchildren exposed to the decrease of meat/fish markets showed the lower obesity risk (OR = 0.57 [95% CI = 0.35–0.91]), especially urban schoolchildren (OR = 0.53 [95% CI = 0.32–0.87]). Results from analyses within 800-m straight-line buffer zones of schools were more consistent with our theory-based hypotheses than those from analyses within 800-m road-network buffer zones of schools and school ZIP codes. Conclusions National data in the USA suggest that long-term exposure to the food environment around schools could affect childhood obesity risk; this association varied across gender and urbanicity. This study has important public health implications for future school-based dietary intervention design and urban planning.