Lactation improves glucose metabolism, but its role in preventing type 2 diabetes mellitus (DM) after gestational diabetes mellitus (GDM) remains uncertain. To evaluate lactation and the 2-year incidence of DM after GDM pregnancy. Prospective, observational cohort of women with recent GDM. (ClinicalTrials.gov: NCT01967030). Integrated health care system. 1035 women diagnosed with GDM who delivered singletons at 35 weeks’ gestation or later and enrolled in the Study of Women, Infant Feeding and Type 2 Diabetes After GDM Pregnancy from 2008 to 2011. Three in-person research examinations from 6 to 9 weeks after delivery (baseline) and annual follow-up for 2 years that included 2-hour, 75-g oral glucose tolerance testing; anthropometry; and interviews. Multivariable Weibull regression models evaluated independent associations of lactation measures with incident DM adjusted for potential confounders. Of 1010 women without diabetes at baseline, 959 (95%) were evaluated up to 2 years later; 113 (11.8%) developed incident DM. There were graded inverse associations for lactation intensity at baseline with incident DM and adjusted hazard ratios of 0.64, 0.54, and 0.46 for mostly formula or mixed/inconsistent, mostly lactation, and exclusive lactation versus exclusive formula feeding, respectively (P trend = 0.016). Time-dependent lactation duration showed graded inverse associations with incident DM and adjusted hazard ratios of 0.55, 0.50, and 0.43 for greater than 2 to 5 months, greater than 5 to 10 months, and greater than 10 months, respectively, versus 0 to 2 months (P trend = 0.007). Weight change slightly attenuated hazard ratios. Randomized design is not feasible or desirable for clinical studies of lactation. Higher lactation intensity and longer duration were independently associated with lower 2-year incidences of DM after GDM pregnancy. Lactation may prevent DM after GDM delivery. National Institute of Child Health and Human Development.