Childhood overweight and obesity is a global public health problem. Rapid infant weight gain is predictive of childhood overweight. Studies found that exposure to ambient air pollution is associated with childhood overweight, and have linked prenatal exposure to air pollution with rapid infant weight gain. To examine the association between prenatal and postnatal ambient NO2 exposure, a traffic-related marker, with rapid weight gain in infants. We carried out a population-based historical cohort study using data from the Israeli national network of maternal and child health clinics. The study included 474,136 infants born at term with birthweight ≥2500 g in 2011-2019 in central Israel. Weekly averages of NO2 concentration throughout pregnancy (prenatal) and the first 4 weeks of life (postnatal) were assessed using an optimized dispersion model and were linked to geocoded home addresses. We modelled weight gain velocity throughout infancy using the SuperImposition by Translation and Rotation (SITAR) method, a mixed-effects nonlinear model specialized for modelling growth curves, and defined rapid weight gain as the highest velocity tertile. Distributed-lag models were used to assess critical periods of risk and to measure relative risks for rapid weight gain. Adjustments were made for socioeconomic status, population group, subdistrict, month and year of birth, and the alternate exposure period - prenatal or postnatal. The cumulative adjusted relative risk for rapid weight gain of NO2 exposure was 1.02 (95% confidence intereval [CI] 1.00, 1.04) for exposure throughout pregnancy and 1.02 (95% CI 1.01, 1.04) for exposure during the first four postnatal weeks per NO2 interquartile range increase (7.3 ppb). An examination of weekly associations revealed that the critical period of risk for the prenatal exposure was from mid-pregnancy to birth. Prenatal and postnatal exposures to higher concentrations of traffic-related air pollution are each independently associated with rapid infant weight gain, a risk factor for childhood overweight and obesity.