To assess 1) the association between metabolic dysfunction-associated steatotic liver disease (MASLD) in pediatric obesity and youth-onset type 2 diabetes, 2) the joint effect of MASLD and intermediate hyperglycemia on type 2 diabetes risk, and 3) the effect of obesity treatment on type 2 diabetes risk. A cohort study using the Swedish Childhood Obesity Treatment Register (Barnobesitas Registret i Sverige [BORIS]) (1999-2020) linked with national registers was conducted. We included 10,346 children with overweight or obesity and 59,336 matched control individuals. MASLD was defined by transaminases and diagnosis code, separately. Type 2 diabetes was ascertained from national registers. In the obesity cohort, median age at type 2 diabetes diagnosis was 16.9 (quartile 1 [Q1], quartile 3 [Q3]: 14.7, 21.4) years, median follow-up was 8.1 (Q1, Q3: 5.1, 11.7) years. Cumulative incidence of type 2 diabetes at age 30 was 22.7% (obesity and MASLD), 9.9% (obesity alone), and 0.7% (control individuals). MASLD was associated with risk for type 2 diabetes (hazard ratio [HR] 2.71 [95% CI 2.14-3.43]), independently of age, sex, degree of obesity, intermediate hyperglycemia, and parental type 2 diabetes. Joint effect of MASLD and intermediate hyperglycemia increased type 2 diabetes risk (HR 9.04 [6.38-12.79]). Optimal response in obesity treatment reduced the risk (HR 0.23 [0.09-0.57]). MASLD, defined by transaminases or diagnosis code, in pediatric obesity is associated with increased risk for youth-onset type 2 diabetes. MASLD interacts synergistically with intermediate hyperglycemia to dramatically increase the risk. Optimal response in obesity treatment reduces type 2 diabetes risk, despite MASLD.