BACKGROUND: Associations of obesity with incidence of heart failure have been observed, but the causality is uncertain. We hypothesized that gastric bypass surgery leads to a lower incidence of heart failure compared with intensive lifestyle modification in obese people. METHODS: We included obese people without previous heart failure from a Swedish nationwide registry of people treated with a structured intensive lifestyle program and the Scandinavian Obesity Surgery Registry. All analyses used inverse probability weights based on baseline body mass index and a propensity score estimated from baseline variables. Treatment groups were well balanced in terms of weight, body mass index, and most potential confounders. Associations of treatment with heart failure incidence, as defined in the National Patient Register, were analyzed with Cox regression. RESULTS: The 25 804 gastric bypass surgery patients had on average lost 18.8 kg more weight after 1 year and 22.6 kg more after 2 years than the 13 701 lifestyle modification patients. During a median of 4.1 years, surgery patients had lower heart failure incidence than lifestyle modification patients (hazard ratio, 0.54; 95% confidence interval, 0.36-0.82). A 10-kg achieved weight loss after 1 year was related to a hazard ratio for heart failure of 0.77 (95% confidence interval, 0.60-0.97) in both treatment groups combined. Results were robust in sensitivity analyses. CONCLUSIONS: Gastric bypass surgery was associated with approximately one half the incidence of heart failure compared with intensive lifestyle modification in this study of 2 large nationwide registries. We also observed a graded association between increasing weight loss and decreasing risk of heart failure.