To determine the prevalence of autism spectrum disorders (ASD) across gestational age, examine the risk of ASD by gestational age controlling for other risk factors, and identify potential risk factors in the neonatal intensive care unit. A retrospective cohort of infants born at ? 24 weeks between January 1, 2000, and December 31, 2007 at 11 Kaiser Permanente Northern California hospitals (n = 195,021). ASD cases were defined by a diagnosis made at a Kaiser Permanente ASD evaluation center, by a clinical specialist, or by a pediatrician. Cox proportional hazards regression models were used to evaluate the association between gestational age and ASD as well as potential risk factors in the neonatal intensive care unit and ASD. The prevalence of ASD in infants <37 weeks was 1.78% compared with 1.22% in infants born ? 37 weeks (P < .001). Compared with term infants, infants born at 24-26 weeks had an adjusted hazard ratio (HR) for a diagnosis of ASD of 2.7 (95% CI 1.5-5.0). Infants born at 27-33 weeks (adjusted HR 1.4, 95% CI 1.1-1.8) and 34-36 weeks (adjusted HR 1.3, 95% CI 1.1-1.4) were also at increased risk. High frequency ventilation and intracranial hemorrhage were associated with ASD in infants < 34 weeks. ASD was ~ 3 times more prevalent in infants <27 weeks compared with term infants. Each week of shorter gestation was associated with an increased risk of ASD. High frequency ventilation and intracranial hemorrhage were associated with ASD among infants <34 weeks.