Nonalcoholic fatty liver disease (NAFLD) is the most common liver disease worldwide, yet the pathogenesis of NAFLD is only partially understood. Here, we investigated the role of the gut bacteria in NAFLD by stimulating the gut bacteria via feeding mice the fermentable dietary fiber, guar gum (GG), and suppressing the gut bacteria via chronic oral administration of antibiotics. GG feeding profoundly altered the gut microbiota composition, in parallel with reduced diet-induced obesity and improved glucose tolerance. Strikingly, despite reducing adipose tissue mass and inflammation, GG enhanced hepatic inflammation and fibrosis, concurrent with markedly elevated plasma and hepatic bile acid levels. Consistent with a role of elevated bile acids in the liver phenotype, treatment of mice with taurocholic acid stimulated hepatic inflammation and fibrosis. In contrast to GG, chronic oral administration of antibiotics effectively suppressed the gut bacteria, decreased portal secondary bile acid levels, and attenuated hepatic inflammation and fibrosis. Neither GG nor antibiotics influenced plasma lipopolysaccharide levels. In conclusion, our data indicate a causal link between changes in gut microbiota and hepatic inflammation and fibrosis in a mouse model of NAFLD, possibly via alterations in bile acids.