Background Emerging evidence suggests that the in utero environment is not sterile as once presumed. Work in the mouse demonstrated transmission of commensal bacteria from mother to fetus during gestation, though it is unclear what modulates this process. We have previously shown in the nonhuman primate that, independent of obesity, a maternal high-fat diet during gestation and lactation persistently shapes the juvenile gut microbiome. We therefore sought to interrogate in a population-based human longitudinal cohort whether a maternal high-fat diet similarly alters the neonatal and infant gut microbiome in early life. Methods A representative cohort was prospectively enrolled either in the early third trimester or intrapartum (n = 163), with a subset consented to longitudinal sampling through the postpartum interval (n = 81). Multiple body site samples, including stool and meconium, were collected from neonates at delivery and by 6 weeks of age. A rapid dietary questionnaire was administered to estimate intake of fat, added sugars, and fiber over the past month (National Health and Examination Survey). DNA was extracted from each infant meconium/stool sample (MoBio) and subjected to 16S rRNA gene sequencing and analysis. Results On average, the maternal dietary intake of fat ranged from 14.0 to 55.2 %, with an average intake of 33.1 % (σ = 6.1 %). Mothers whose diets significantly differed from the mean (±1 standard deviation) were separated into two distinct groups, a control group (n = 13, μ = 24.4 %) and a high-fat group (n = 13, μ = 43.1 %). Principal coordinate analysis revealed that the microbiome of the neonatal stool at birth (meconium) clustered differently by virtue of maternal gestational diet (PERMANOVA p = 0.001). LEfSe feature selection identified several taxa that discriminated the groups, with a notable relative depletion of Bacteroides in the neonates exposed to a maternal high-fat gestational diet (Student’s t-test, p < 0.05) that persisted to 6 weeks of age. Conclusions Similar to the primate, independent of maternal body mass index, a maternal high-fat diet is associated with distinct changes in the neonatal gut microbiome at birth which persist through 4–6 weeks of age. Our findings underscore the importance of counseling pregnant mothers on macronutrient consumption during pregnancy and lactation. Electronic supplementary material The online version of this article (doi:10.1186/s13073-016-0330-z) contains supplementary material, which is available to authorized users.