To determine whether cardiac functional and structural changes in fetuses of mothers with gestational diabetes mellitus (GDM) persist in the offspring beyond the neonatal period. Longitudinal study. Fetal Medicine Unit in a UK teaching hospital. 73 women with GDM and 73 women with uncomplicated pregnancy were recruited and fetal cardiac scans were performed at 35-36weeks' gestation. Repeat echocardiogram was performed in their offspring during infancy. Fetal and infant cardiac functional and structural changes. Fetuses of mothers with GDM, compared with controls, had more globular right ventricles (sphericity index 0.7, interquartile range [IQR] 0.6/0.7 versus 0.6, IQR 0.5/0.6, P<0.001) and reduced right global longitudinal systolic strain (-16.4, IQR -18.9/-15.3 versus -18.5, IQR -20.6/-16.8, P=0.001) and left global longitudinal systolic strain (-20.1, IQR -22.5/-16.9 versus -21.3, IQR -23.5/-19.5), P=0.021). In the GDM group, compared with controls, in infancy there was higher left ventricular E/e' (8.7, IQR 7.3/9.7 versus 7.9 IQR, 6.8/8.9 P=0.011) and lower left ventricular global longitudinal systolic strain (-21.0, IQR -22.5/-19.4 versus -22.3, IQR -23.5/-20.7, P=0.001) and tricuspid annular plane systolic excursion (13.8, IQR 12.7/16.1 versus 15.2, IQR 13.8/16.8, P=0.003). These differences remained following multivariable analysis. Gestational diabetes mellitus is associated with alterations in fetal cardiac function and structure compared with controls and persistent cardiac changes in infancy. Gestational diabetes mellitus, even when well controlled, is associated with fetal cardiac changes and these persist in infancy.