The gut microbiota is recognized to have an important role in energy storage and the subsequent development of obesity. To date, bariatric surgery (indicated for severe obesity) represents the only treatment that enables substantial and sustained weight loss. Bariatric surgery is also a good model to study not only the pathophysiology of obesity and its related diseases but also the mechanisms involved in their improvement after weight reduction. Scarce data from humans and animal models have demonstrated that gut microbiota composition is modified after Roux-en-Y gastric bypass (RYGB), suggesting that weight reduction could affect gut microbiota composition. However, weight loss might not be the only factor responsible for those modifications. Indeed, bariatric surgery not only improves hormonal and inflammatory status, but also induces numerous changes in the digestive tract that might account for the observed modifications of microbiota ecology. In future bariatric surgery studies in humans or mice, these major surgery-induced modifications will need to be taken into account when analyzing the link between gut microbiota composition, obesity, its complications and their improvement after bariatric surgery. This Review outlines the potential mechanisms by which the major changes in the digestive tract after bariatric surgery can affect the gut microbiota.