Motor vehicle exhaust is a major contributor to air pollution, and exposure to benzene or other carcinogenic components may increase cancer risks. We aimed to investigate the association between traffic-related air pollution and risk of childhood cancer in a nationwide cohort study in Switzerland. We identified incident cases from the Swiss Childhood Cancer Registry diagnosed<16years of age between 1990 and 2015 and linked them probabilistically with the census-based Swiss National Cohort study. We developed land use regression models to estimate annual mean ambient levels of nitrogen dioxide (NO2) and benzene outside 1.4 million children's homes. We used risk-set sampling to facilitate the analysis of time-varying exposure and fitted conditional logistic regression models adjusting for neighborhood socio-economic position, level of urbanization, and background ionizing radiation. We included 2,960 cancer cases in the analyses. The adjusted hazard ratios (HR) and 95% confidence intervals for exposure to NO2 per 10μg/m3 were 1.00 (95%-CI 0.88-1.13) for acute lymphoblastic leukemia (ALL) and 1.31 (95%-CI 1.00-1.71) for acute myeloid leukemia (AML). Using exposure lagged by 1 to 5years instead of current exposure attenuated the effect for AML. The adjusted HR for exposure to benzene per 1μg/m3 was 1.03 (95%-CI 0.86-1.23) for ALL and 1.29 (95%-CI 0.86-1.95) for AML. We also observed increased HRs for other diagnostic groups, notably non-Hodgkin lymphoma. Our study adds to the existing evidence that exposure to traffic-related air pollution is associated with an increased risk of childhood leukemia, particularly AML.