Background Pediatric obesity is associated with increased risk of premature death from middle age onward, but whether the risk is already increased in young adulthood is unclear. The aim was to investigate whether individuals who had obesity in childhood have an increased mortality risk in young adulthood, compared with a population-based comparison group. Methods and findings In this prospective cohort study, we linked nationwide registers and collected data on 41,359 individuals. Individuals enrolled at age 3-17.9 years in the Swedish Childhood Obesity Treatment Register (BORIS) and living in Sweden on their 18th birthday (start of followup) were included. A comparison group was matched by year of birth, sex, and area of residence. We analyzed all-cause mortality and cause-specific mortality using Cox proportional hazards models, adjusted according to group, sex, Nordic origin, and parental socioeconomic status (SES). Over 190,752 person-years of follow-up (median follow-up time 3.6 years), 104 deaths were recorded. Median (IQR) age at death was 22.0 (20.0-24.5) years. In the childhood obesity cohort, 0.55% (n = 39) died during the follow-up period, compared to 0.19% (n = 65) in the comparison group (p < 0.001). More than a quarter of the deaths among individuals in the childhood obesity cohort had obesity recorded as a primary or contributing cause of death. Male sex and low parental SES were associated with premature all-cause mortality. Suicide and self-harm with undetermined intent were the main cause of death in both groups. The largest difference between the groups lay within endogenous causes of death, where children who had undergone obesity treatment had an adjusted mortality rate ratio of 4.04 (95% CI 2.00-8.17, p < 0.001) compared with the comparison group. The main study limitation was the lack of anthropometric data in the comparison group.