Systemic inflammation, which can be induced by metabolic endotoxemia, and corresponding high‑fat diet‑mediated metabolic disorders are associated with gut microbiota. In the present study reverse transcription-polymerase chain reaction, immunofluorescence, pyrosequencing, ELISA and Oil Red O staining were performed to assess whether berberine can protect against diet-induced obesity, through modulating the gut microbiota and consequently improving metabolic endotoxemia and gastrointestinal hormone levels. Alterations in the gut microbiota induced by berberine resulted in a significant reduction in bacterial lipopolysaccharide levels in portal plasma. Levels of inflammatory and oxidative stress markers, as well as the mRNA expression levels of macrophage infiltration markers in visceral adipose tissue, were also reduced by berberine. Inhibition of the inflammatory response was associated with a reduction in intestinal permeability and an increase in the expression of tight junction proteins. In addition, berberine was reported to restore aberrant levels of gut hormones in the portal plasma, such as glucagon‑like peptide‑1 and ‑2, peptide YY, glucose‑dependent insulinotropic polypeptide and pancreatic polypeptide. The present findings indicated that berberine, through modulating gut microbiota, restored the gut barrier, reduced metabolic endotoxemia and systemic inflammation, and improved gut peptide levels in high‑fat diet‑fed rats. The present study suggests that berberine may be an effective therapeutic strategy for the treatment of obesity and insulin resistance.