Obesity shortens life expectancy. Bariatric surgery is known to reduce the long-term relative risk of death, but its effect on life expectancy is unclear. We used the Gompertz proportional hazards regression model to compare mortality and life expectancy among patients treated with either bariatric surgery (surgery group) or usual obesity care (control group) in the prospective, controlled Swedish Obese Subjects (SOS) study and participants in the SOS reference study (reference cohort), a random sample from the general population. In total, 2007 and 2040 patients were included in the surgery group and the control group, respectively, and 1135 participants were included in the reference cohort. At the time of the analysis (December 31, 2018), the median duration of follow-up for mortality was 24 years (interquartile range, 22 to 27) in the surgery group and 22 years (interquartile range, 21 to 27) in the control group; data on mortality were available for 99.9% of patients in the study. In the SOS reference cohort, the median duration of follow-up was 20 years (interquartile range, 19 to 21), and data on mortality were available for 100% of participants. In total, 457 patients (22.8%) in the surgery group and 539 patients (26.4%) in the control group died (hazard ratio, 0.77; 95% confidence interval [CI], 0.68 to 0.87; P<0.001). The corresponding hazard ratio was 0.70 (95% CI, 0.57 to 0.85) for death from cardiovascular disease and 0.77 (95% CI, 0.61 to 0.96) for death from cancer. The adjusted median life expectancy in the surgery group was 3.0 years (95% CI, 1.8 to 4.2) longer than in the control group but 5.5 years shorter than in the general population. The 90-day postoperative mortality was 0.2%, and 2.9% of the patients in the surgery group underwent repeat surgery. Among patients with obesity, bariatric surgery was associated with longer life expectancy than usual obesity care. Mortality remained higher in both groups than in the general population. (Funded by the Swedish Research Council and others; SOS ClinicalTrials.gov number, NCT01479452.).