Berberine, a major pharmacological component of the Chinese herb Coptis chinensis, which was originally used to treat bacterial diarrhea, has recently been demonstrated to be clinically effective in alleviating type 2 diabetes. In this study, we revealed that berberine effectively prevented the development of obesity and insulin resistance in high-fat diet (HFD)-fed rats, which showed decreased food intake. Increases in the levels of serum lipopolysaccharide-binding protein, monocyte chemoattractant protein-1, and leptin and decrease in the serum level of adiponectin corrected for body fat in HFD-fed rats were also significantly retarded by the co-administration of berberine at 100 mg/kg body weight. Bar-coded pyrosequencing of the V3 region of 16S rRNA genes revealed a significant reduction in the gut microbiota diversity of berberine-treated rats. UniFrac principal coordinates analysis revealed a marked shift of the gut microbiota structure in berberine-treated rats away from that of the controls. Redundancy analysis identified 268 berberine-responding operational taxonomic units (OTUs), most of which were essentially eliminated, whereas a few putative short-chain fatty acid (SCFA)-producing bacteria, including Blautia and Allobaculum, were selectively enriched, along with elevations of fecal SCFA concentrations. Partial least square regression models based on these 268 OTUs were established (Q(2)>0.6) for predicting the adiposity index, body weight, leptin and adiponectin corrected for body fat, indicating that these discrete phylotypes might have a close association with the host metabolic phenotypes. Taken together, our findings suggest that the prevention of obesity and insulin resistance by berberine in HFD-fed rats is at least partially mediated by structural modulation of the gut microbiota, which may help to alleviate inflammation by reducing the exogenous antigen load in the host and elevating SCFA levels in the intestine.