Women with gestational diabetes mellitus (GDM) are at increased risk of poor perinatal mental health outcomes. However, the association between GDM and the mother–infant relationship is unclear. This study aimed to examine whether GDM itself impacts the mother–infant relationship and maternal mental health using a cohort study design. We used data from the Cohort of Newborns in Emilia-Romagna (CoNER) study, which included 642 women recruited in Bologna, Italy. Psychological data were collected at 6 and 15 months postnatally using a purpose designed measure to examine the mother–infant relationship. We used linear fixed effects and mixed-effects models to assess the effect of GDM on relationship scores at 6 and 15 months postpartum. Women with GDM had significantly lower relationship scores at 15 months postpartum [β − 1.75 95% CrI (−3.31; −0.21)] but not at 6 months [β − 0.27 95% CrI (−1.37; 0.81)]. Mother–infant relationship scores were significantly lower overall at 15 months compared to 6 months postpartum [β − 0.29 95% CrI (−0.56; −0.02)]. Our findings suggest that there may be a delayed effect on the mother–infant relationship in response to the experience of GDM. Future research using large birth cohorts should investigate this further to confirm these findings, and whether women with GDM would benefit from early interventions to improve relationships taking into account length of time postpartum.