The aim of the present study was to assess the long-term effects of a high-energy-dense diet, supplemented with Lactobacillus plantarum (Lp) or Escherichia coli (Ec), on weight gain, fattening and the gut microbiota in rats. Since the mother's dietary habits can influence offspring physiology, dietary regimens started with the dams at pregnancy and throughout lactation and continued with the offspring for 6 months. The weight gain of group Lp was lower than that of groups C (control) and Ec (P = 0·086). More retroperitoneal adipose tissue (P = 0·030) and higher plasma leptin (P = 0·035) were observed in group Ec compared with group Lp. The viable count of Enterobacteriaceae was higher in group Ec than in group Lp (P = 0·019), and when all animals were compared, Enterobacteriaceae correlated positively with body weight (r 0·428, P = 0·029). Bacterial diversity was lower in group Ec than in groups C (P ≤ 0·05) and Lp (P ≤ 0·05). Firmicutes, Bacteroidetes and Verrucomicrobia dominated in all groups, but Bacteroidetes were more prevalent in group C than in groups Lp (P = 0·036) and Ec (P = 0·056). The same five bacterial families dominated the microbiota of groups Ec and C, and four of these were also present in group Lp. The other five families dominating in group Lp were not found in any of the other groups. Multivariate data analysis pointed in the same directions as the univariate statistics. The present results suggest that supplementation of L. plantarum or E. coli can have long-term effects on the composition of the intestinal microbiota, as well as on weight gain and fattening.