The mucosal surfaces of mammals are densely colonized with microorganisms that are commonly referred to as the commensal microbiota. It is believed that the fetus in utero is sterile and that colonization with microorganisms starts only after birth. Nevertheless, the unborn fetus is exposed to a multitude of metabolites that originate from the commensal microbiota of the mother that reach systemic sites of the maternal body. The intestinal microbiota is strongly personalized and influenced by environmental factors, including nutrition. Members of the maternal microbiota can metabolize dietary components, pharmaceuticals and toxins, which can subsequently be passed to the developing fetus or the breast-feeding neonate. In this Review, we discuss the complex interplay between nutrition, the maternal microbiota and ingested chemicals, and summarize their effects on immunity in the offspring.