Evaluate whether a tailored letter improved gestational weight gain (GWG) and whether GWG mediated a multicomponent intervention’s effect on postpartum weight retention among women with gestational diabetes mellitus (GDM). A cluster-randomized controlled trial of 44 medical facilities (n = 2,014 women) randomized to usual care or a multicomponent lifestyle intervention delivered during pregnancy (tailored letter) and postpartum (13 telephone sessions) to reduce postpartum weight retention. The tailored letter, using electronic health record (EHR) data, recommended an end-of-pregnancy weight goal tailored to prepregnancy BMI and GWG trajectory at GDM diagnosis: total GWG at the lower limit of the IOM range if BMI ≥18.5 kg/m2 or the midpoint if <18.5 kg/m2 and weight maintenance if women had exceeded this. The outcomes for this study were the proportion of women meeting the Institute of Medicine (IOM) guidelines for weekly rate of GWG from GDM diagnosis to delivery and meeting the end-of-pregnancy weight goal. The tailored letter significantly increased the proportion of women meeting the IOM guidelines (72.6% vs. 67.1%; relative risk 1.08 [95% CI 1.01-1.17]); results were similar among women with BMI <25.0 kg/m2 (1.07 [1.00-1.15]) and ≥25.0 kg/m2 (1.08 [0.98-1.18]). Thirty-six percent in the intervention vs. 33.0% in usual care met the end-of-pregnancy weight goal (1.08 [0.99-1.18]); the difference was statistically significant among women with BMI <25.0 kg/m2 (1.28 [1.05-1.57]) but not ≥25.0 kg/m2 (0.99 [0.87-1.13]). Meeting the IOM guidelines mediated the effect of the multicomponent intervention in reducing postpartum weight retention by 24.6% (11.3-37.8%). A tailored EHR-based letter improved GWG, which mediated the effect of a multicomponent intervention in reducing postpartum weight retention.