Air pollutants have been linked to some diseases in humans, but their effects on the nervous system were less frequently evaluated. Autism spectrum disorder (ASD) is a group of neurondevelopmental disorders of which the etiology is still unknown. We conducted a study in Taiwan to evaluate the possible associations between prenatal exposure to air pollutants and ASD. From a random sample of one million people in the National Insurance Research Database, we identified all the infants born between 1996 and 2000. We followed them till the end of 2013 and identified cases of ASD. We traced back the mothers’ residence and assessed the exposure to air pollutants using the data obtained from the air quality monitoring database maintained by the government, which included ozone (O3), carbon monoxide (CO), nitrogen dioxide (NO2), sulfur dioxide (SO2), and particulate matters with diameter less than 10 µm (PM10). Cox proportional hazard models were constructed to evaluate the associations between childhood ASD and exposures to the pollutants in the three trimesters and the whole gestation. We identified a total of 63,376 newborns and included 62,919 as the study cohort. After adjusting for other risk factors, we observed trimester-specific associations between levels of CO, NO2, and PM10 and the risk of childhood ASD. An increase of 1 ppm of CO in the first, second, and third trimester was associated with a hazard ratio (HR) of 1.93 (95% confidence interval [CI]: 1.55–2.39), 1.77 (95%CI: 1.41–2.22), and 1.75 (95%CI: 1.39–2.21), respectively. An increase of 10 ppb in the level of NO2 in the first, second, and third trimester was associated with an HR of 1.39 (95%CI: 1.22–1.58), 1.25 (95%CI: 1.10–1.42), and 1.18 (95%CI: 1.03–1.34), respectively. In conclusion, we found that exposures to CO and NO2 in all three trimesters were associated with increased risks of developing ASD.