One postpartum behaviour that may be protective against diabetes is lactation due to its potential role in resetting maternal metabolism after pregnancy. However, the role of lactation in maternal risk of diabetes has not been investigated in Latin American populations, where rates of breastfeeding are suboptimal and diabetes incidence is increasing. Therefore, our aim was to estimate the association between mean duration of lactation per child and maternal incidence of diabetes. We followed 66,573 women from the Mexican Teachers' Cohort free of diabetes at baseline. Incident diabetes was ascertained through triennial questionnaires and lactation history was asked in baseline questionnaire. We used Cox proportional hazards regression models to estimate the hazard ratio (HR) for diabetes by mean duration of lactation per child. We examined the dose–response association between lactation per child and diabetes with restricted cubic splines. We found that 3,168 incident cases of diabetes were diagnosed during 157,510 person years of follow‐up. In comparison with women who did not breastfed, women with a mean lactation per child of 3 to <6 months and 6 to <12 months had HRs of 0.81 (95% CI [0.65, 0.99]) and 0.73 (95% CI [0.59, 0.91]), respectively (p for quadratic term 0.004). There was no further decline in risk of diabetes after ≥12 months of lactation per child. The dose–response association between lactation and diabetes was linear up to 9 months of lactation. Our findings suggest that lactation is associated with reduced incidence of diabetes, indicating considerable potential for diabetes prevention on a population level.