Introduction The complex etiology of autism spectrum disorder (ASD) is still unresolved. Preterm birth (<37 weeks of gestation) and its complications are the leading cause of death of babies in the world, and those who survive often have long-term health problems. Length of gestation, including preterm birth, has been linked to ASD risk, but robust estimates for the whole range of gestational ages (GAs) are lacking. The primary objective of this study was to provide a detailed and robust description of ASD risk across the entire range of GAs while adjusting for sex and size for GA. Methods and findings Our study had a multinational cohort design, using population-based data from medical registries in three Nordic countries: Sweden, Finland, and Norway. GA was estimated in whole weeks based on ultrasound. Children were prospectively followed from birth for clinical diagnosis of ASD. Relative risk (RR) of ASD was estimated using log-binomial regression. Analyses were also stratified by sex and by size for GA. The study included 3,526,174 singletons