Rapid weight loss is a major risk factor for the formation of cholesterol gallstones. Consequently, patients with morbid obesity undergoing bariatric surgery frequently develop symptomatic gallstone disease. This trial assessed the efficacy of ursodeoxycholic acid versus placebo for the prevention of symptomatic gallstone disease after bariatric surgery. This multicentre, double-blind, randomised, placebo-controlled superiority trial enrolled patients with an intact gallbladder scheduled for laparoscopic Roux-en-Y gastric bypass (RYGB) or sleeve gastrectomy in three hospitals in the Netherlands. Patients were randomly assigned (1:1) by a web-based randomisation module to receive 900 mg ursodeoxycholic acid daily for 6 months or matched placebo. Randomisation was stratified by the presence of asymptomatic gallstones at baseline and type of surgery. Patients, clinicians, and study staff were masked to treatment allocation. The primary endpoint was symptomatic gallstone disease within 24 months, assessed in the modified intention-to-treat population (all randomly assigned eligible patients with any post-randomisation measurement). Prespecified subgroup analyses were done based on the stratification groups. Safety was assessed in all patients who took at least one dose of the study drug. This trial is registered with the Netherlands Trial Register, NL5954. Between Jan 11, 2017, and Oct 22, 2018, 985 patients were randomly assigned to receive either ursodeoxycholic acid (n=492) or placebo (n=493). 967 patients were included in the modified intention-to-treat population, of whom 959 had data available for primary endpoint assessment. 189 (20%) patients had asymptomatic gallstones at baseline and 78 (8%) received a sleeve gastrectomy. Symptomatic gallstone disease occurred in 31 (6·5%) of 475 patients in the ursodeoxycholic acid group and in 47 (9·7%) of 484 patients in the placebo group (relative risk 0·67, 95% CI 0·43-1·04, p=0·071). Logistic regression showed a significant interaction between ursodeoxycholic acid and the presence of asymptomatic gallstones at baseline (p=0·046), with an effect of ursodeoxycholic acid in patients without (0·47, 0·27-0·84, p=0·0081), and no effect in patients with asymptomatic gallstones at baseline (1·22, 0·61-2·47, p=0·57). The effect was stronger in patients without gallstones at baseline undergoing RYGB (0·37, 0·20-0·71, p=0·0016), whereas the subgroup of patients undergoing sleeve gastrectomy was too small to draw clear conclusions. Adverse events were rare. In the ursodeoxycholic acid group, diarrhoea occurred in four (0·9%) of 444 patients and skin rash in two (0·5%) patients. In the placebo group, diarrhoea occurred in two (0·4%) of 453 patients and skin rash in two (0·4%) patients. The total number of serious adverse events did not significantly differ between the trial groups (75 [17%] in 444 patients in the ursodeoxycholic acid group and 102 [23%] in 453 patients in the placebo group). The most common serious adverse events were abdominal pain and internal hernia. No serious adverse event was attributed to the study drug. Ursodeoxycholic acid prophylaxis did not significantly reduce the occurrence of symptomatic gallstone disease in all patients after bariatric surgery. In patients without gallstones before RYGB surgery, ursodeoxycholic acid treatment reduced the occurrence of symptomatic gallstone disease compared with placebo. Further research is needed to assess the efficacy of ursodeoxycholic acid after sleeve gastrectomy. The Netherlands Organization for Health Research and Development, Zambon Netherlands BV, Foundation for Clinical Research of the Slotervaart Hospital, the Spaarne Gasthuis Academy, and Amsterdam Gastroenterology Endocrinology Metabolism.