An adverse intrauterine or periconceptional environment, such as hyperglycemia during pregnancy, can affect the DNA methylation pattern both in mothers and their offspring. In this study, we explored the epigenetic profile in maternal peripheral blood samples through pregnancy to find potential epigenetic biomarkers for gestational diabetes mellitus (GDM), as well as candidate genes involved in GDM development. We performed an epigenome-wide association study in maternal peripheral blood samples in 32 pregnant women (16 with GDM and 16 non-GDM) at pregnancy week 24–28 and 36–38. Biochemical, anthropometric, and obstetrical variables were collected from all the participants. The main results were validated in an independent cohort with different ethnic origin (European = 307; South Asians = 165). Two hundred and seventy-two CpGs sites remained significantly different between GDM and non-GDM pregnant women across two time points during pregnancy. The significant CpG sites were related to pathways associated with type I diabetes mellitus, insulin resistance and secretion. Cg01459453 (SELP gene) was the most differentiated in the GDM group versus non-GDM (73.6 vs. 60.9,p= 1.06E−11; FDR = 7.87E−06). Three CpG sites (cg01459453, cg15329406, and cg04095097) were able to discriminate between GDM cases and controls (AUC = 1;p= 1.26E−09). Three differentially methylated positions (DMPs) were replicated in an independent cohort. To conclude, epigenetic marks during pregnancy differed between GDM cases and controls suggesting a role for these genes in GDM development. Three CpGs were able to discriminate GDM and non-GDM groups with high specificity and sensitivity, which may be biomarker candidates for diagnosis or prediction of GDM.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13148-023-01523-8.