Environmental toxicant exposure, including air pollution, is increasing worldwide. However, toxicant exposures are not equitably distributed. Rather, low-income and minority communities bear the greatest burden, along with higher levels of psychosocial stress. Both air pollution and maternal stress during pregnancy have been linked to neurodevelopmental disorders such as autism, but biological mechanisms and targets for therapeutic intervention remain poorly understood. We demonstrate that combined prenatal exposure to air pollution (diesel exhaust particles, DEP) and maternal stress (MS) in mice induces social behavior deficits only in male offspring, in line with the male bias in autism. These behavioral deficits are accompanied by changes in microglial morphology and gene expression as well as decreased dopamine receptor expression and dopaminergic fiber input in the nucleus accumbens (NAc). Importantly, the gut-brain axis has been implicated in ASD, and both microglia and the dopamine system are sensitive to the composition of the gut microbiome. In line with this, we find that the composition of the gut microbiome and the structure of the intestinal epithelium are significantly shifted in DEP/MS-exposed males. Excitingly, both the DEP/MS-induced social deficits and microglial alterations in males are prevented by shifting the gut microbiome at birth via a cross-fostering procedure. However, while social deficits in DEP/MS males can be reversed by chemogenetic activation of dopamine neurons in the ventral tegmental area, modulation of the gut microbiome does not impact dopamine endpoints. These findings demonstrate male-specific changes in the gut-brain axis following DEP/MS and suggest that the gut microbiome is an important modulator of both social behavior and microglia.