BackgroundAir pollution exposure during pregnancy and childhood has been linked to executive function impairment in children, however, very few studies have assessed these two exposure periods jointly to identify susceptible periods of exposure. We sought to identify potential periods of susceptibility of nitrogen dioxide (NO2) exposure from conception to childhood on attentional function and working memory in school-aged children. MethodsWithin the Spanish INMA Project, we estimated residential daily NO2 exposures during pregnancy and up to 6 years of childhood using land use regression models (n = 1,703). We assessed attentional function at 4–6 years and 6–8 years, using the Conners Kiddie Continuous Performance Test and the Attention Network Test, respectively, and working memory at 6–8 years, using the N-back task. We used distributed lag non-linear models to assess the periods of susceptibility of each outcome, adjusting for potential confounders and correcting for multiple testing. We also stratified all models by sex. ResultsHigher exposure to NO2 between 1.3 and 1.6 years of age was associated with higher hit reaction time standard error (HRT-SE) (0.14 ms (95 % CI 0.05; 0.22) per 10 μg/m3 increase in NO2) and between 1.5 and 2.2 years of age with more omission errors (1.02 (95 % CI 1.01; 1.03) of the attentional function test at 4–6 years. Higher exposure to NO2 between 0.3 and 2.2 years was associated with higher HRT-SE (10.61 ms (95 % CI 3.46; 17.75) at 6–8 years only in boys. We found no associations between exposure to NO2 and working memory at 6–8 years. ConclusionOur findings suggest that NO2 exposure during the first two years of life is associated with poorer attentional function in children from 4 to 8 years of age, especially in boys. These findings highlight the importance of exploring long-term effects of traffic-related air pollution exposure in older age groups.