BackgroundIn utero exposure to maternal hyperglycemia has been associated with an increased risk for the development of chronic diseases in later life. These predispositions may be programmed by fetal DNA methylation (DNAm) changes that persist postnatally. However, although some studies have associated fetal exposure to gestational hyperglycemia with DNAm variations at birth, and metabolic phenotypes in childhood, no study has yet examined how maternal hyperglycemia during pregnancy may be associated with offspring DNAm from birth to five years of age.HypothesisMaternal hyperglycemia is associated with variation in offspring DNAm from birth to 5 years of age.MethodsWe estimated maternal hyperglycemia using the area under the curve for glucose (AUCglu) following an oral glucose tolerance test conducted at 24–30 weeks of pregnancy. We quantified DNAm levels in cord blood (n= 440) and peripheral blood at five years of age (n= 293) using the Infinium MethylationEPIC BeadChip (Illumina). Our total sample included 539 unique dyads (mother–child) with 194 dyads having DNAm at both time-points. We first regressed DNAmM-values against the cell types and child age for each time-point separately to account for the difference by time of measurement for these variables. We then used a random intercept model from the linear mixed model (LMM) framework to assess the longitudinal association between maternal AUCglu and the repeated measures of residuals of DNAm. We adjusted for the following covariates as fixed effects in the random intercept model: maternal age, gravidity, smoking status, child sex, maternal body mass index (BMI) (measured at first trimester of pregnancy), and a binary variable for time-point.ResultsIn utero exposure to higher maternal AUCgluwas associated with lower offspring blood DNAm levels at cg00967989 located inFSD1Lgene (β= − 0.0267,P= 2.13 × 10–8) in adjusted linear regression mixed models. Our study also reports other CpG sites for which DNAm levels were suggestively associated (P< 1.0 × 10–5) with in utero exposure to gestational hyperglycemia. Two of these (cg12140144 and cg07946633) were found in the promotor region ofPRDM16gene (β: − 0.0251,P= 4.37 × 10–07andβ: − 0.0206,P= 2.24 × 10–06, respectively).ConclusionMaternal hyperglycemia is associated with offspring DNAm longitudinally assessed from birth to 5 years of age.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13148-023-01524-7.