Background There are concerns that current gestational weight gain recommendations for women with obesity are too high and that guidelines should differ on the basis of severity of obesity. In this study we investigated the safety of gestational weight gain below current recommendations or weight loss in pregnancies with obesity, and evaluated whether separate guidelines are needed for different obesity classes. Methods In this population -based cohort study, we used electronic medical records from the Stockholm-Gotland Perinatal Cohort study to identify pregnancies with obesity (early pregnancy BMI before 14 weeks' gestation >= 30 kg/m( 2 )) among singleton pregnancies that delivered between Jan 1, 2008, and Dec 31, 2015. The pregnancy records were linked with Swedish national health-care register data up to Dec 31, 2019. Gestational weight gain was calculated as the last measured weight before or at delivery minus early pregnancy weight (at <14 weeks' gestation), and standardised for gestational age into z -scores. We used Poisson regression to assess the association of gestational weight gain z -score with a composite outcome of: stillbirth, infant death, large for gestational age and small for gestational age at birth, preterm birth, unplanned caesarean delivery, gestational diabetes, pre-eclampsia, excess postpartum weight retention, and new -onset longer -term maternal cardiometabolic disease after pregnancy, weighted to account for event severity. We calculated rate ratios (RRs) for our composite adverse outcome along the weight gain z -score continuum, compared with a reference of the current lower limit for gestational weight gain recommended by the US Institute of Medicine (IOM; 5 kg at term). RRs were adjusted for confounding factors (maternal age, height, parity, early pregnancy BMI, early pregnancy smoking status, prepregnancy cardiovascular disease or diabetes, education, cohabitation status, and Nordic country of birth). Findings Our cohort comprised 15 760 pregnancies with obesity, followed up for a median of 7<middle dot>9 years (IQR 5<middle dot>8-9<middle dot>4). 11 667 (74<middle dot>0%) pregnancies had class 1 obesity, 3160 (20<middle dot>1%) had class 2 obesity, and 933 (5<middle dot>9%) had class 3 obesity. Among these pregnancies, 1623 (13<middle dot>9%), 786 (24<middle dot>9%), and 310 (33<middle dot>2%), respectively, had weight gain during pregnancy below the lower limit of the IOM recommendation (5 kg). In pregnancies with class 1 or 2 obesity, gestational weight gain values below the lower limit of the IOM recommendation or weight loss did not increase risk of the adverse composite outcome (eg, at weight gain z -score -2<middle dot>4, corresponding to 0 kg at 40 weeks: adjusted RR 0<middle dot>97 [95% CI 0<middle dot>89-1<middle dot>06] in obesity class 1 and 0<middle dot>96 [0<middle dot>86-1<middle dot>08] in obesity class 2). In pregnancies with class 3 obesity, weight gain values below the IOM limit or weight loss were associated with reduced risk of the adverse composite outcome (eg, adjusted RR 0<middle dot>81 [0<middle dot>71-0<middle dot>89] at weight gain z -score -2<middle dot>4, or 0 kg). Interpretation Our findings support calls to lower or remove the lower limit of current IOM recommendations for pregnant women with obesity, and suggest that separate guidelines for class 3 obesity might be warranted.