Pregnancy can alter gut microbiota composition, but how an obesogenic diet impacts maternal gut microbiota, and the extent to which this influences offspring microbiome can be obscured by confounding factors. This study examined changes in gut microbiota composition prior to pregnancy, and across gestation and lactation in rat dams fed either a high-fat, high-sugar Cafeteria (Caf) diet or Chow. Microbiome development was assessed in their offspring weaned onto chow. Caf diet consumption during pregnancy increased weight gain and adiposity, and lowered plasma folate and B12 levels. α- and β diversity measures in Caf-fed dams showed a different trajectory across the progression of pregnancy, with no change in Bacteroidetes and Firmicutes abundance compared with Chow dams, who showed reduced Firmicutes at gestation and mid-lactation. Offspring born to Caf dams exhibited greater adiposity and plasma leptin at weaning (3 weeks) and 14 weeks of age than those born to Chow dams. Maternal plasma folate levels were positively associated with maternal and weanling gut microbiota, specifically with OTU2_Romboutsia and OTU3_Lactobacillus relative abundance. Maternal Caf diet induced clear differences in β diversity in weanlings but not α diversity. SourceTracker analysis revealed similarities in the gut microbiota of Chow weanlings and those of their mothers during lactation, whereas the microbiota of Caf weanlings was similar to the Caf maternal gut microbiota during gestation. Maternal Caf diet exerted only marginal effects on gut microbiota composition in 14-week-old offspring consuming regular chow.