Exposure to prenatal infection has been suggested to cause deficiencies in fetal neurodevelopment. In this study we included all children born in Denmark from 1980, through 2005. Diagnoses of autism spectrum disorders (ASDs) and maternal infection were obtained through nationwide registers. Data was analyzed using Cox proportional hazards regression. No association was found between any maternal infection and diagnosis of ASDs in the child when looking at the total period of pregnancy: adjusted hazard ratio = 1.14 (CI: 0.96-1.34). However, admission to hospital due to maternal viral infection in the first trimester and maternal bacterial infection in the second trimester were found to be associated with diagnosis of ASDs in the offspring, adjusted hazard ratio = 2.98 (CI: 1.29-7.15) and adjusted hazard ratio = 1.42 (CI: 1.08-1.87), respectively. Our results support prior hypotheses concerning early prenatal viral infection increasing the risk of ASDs.