Maternal immune activation (MIA) contributes to behavioural abnormalities associated with neurodevelopmental disorders in both primate and rodent offspring. In humans, epidemiological studies suggest that exposure of fetuses to maternal inflammation increases the likelihood of developing autism spectrum disorder. In pregnant mice, interleukin-17a (IL-17a) produced by T helper 17 (TH17) cells (CD4+ T helper effector cells involved in multiple inflammatory conditions) induces behavioural and cortical abnormalities in the offspring exposed to MIA. However, it is unclear whether other maternal factors are required to promote MIA-associated phenotypes. Moreover, the underlying mechanisms by which MIA leads to T cell activation with increased IL-17a in the maternal circulation are not well understood. Here we show that MIA phenotypes in offspring require maternal intestinal bacteria that promote TH17 cell differentiation. Pregnant mice that had been colonized with mouse commensal segmented filamentous bacteria or human commensal bacteria that induce intestinal TH17 cells were more likely to produce offspring with MIA-associated abnormalities. We also show that small intestine dendritic cells from pregnant, but not from non-pregnant, females secrete IL-1β, IL-23 and IL-6 and stimulate T cells to produce IL-17a upon exposure to MIA. Overall, our data suggest that defined gut commensal bacteria with a propensity to induce TH17 cells may increase the risk of neurodevelopmental disorders in the offspring of pregnant mothers undergoing immune system activation owing to infections or autoinflammatory syndromes.