This study aimed to explore the mediation effects of one-carbon metabolism (OCM) related nutrients on the association between MTHFR rs1801133 polymorphism and gestational diabetes mellitus (GDM). Folate, vitamin B12 and homocysteine (Hcy) were measured in the serum of 1254 pregnant women. Linear and logistic regressions were used to estimate the associations of OCM nutrients and MTHFR rs1801133 polymorphism with blood glucose levels and GDM risk. Mediation analysis was applied to test the mediation effects of folate, vitamin B12 and Hcy on the association of MTHFR rs1801133 polymorphism with blood glucose concentrations and GDM. Pregnant women with MTHFR rs1801133 CC genotype had higher serum folate (10·75 v. 8·90 and 9·40 ng/ml) and lower serum Hcy (4·84 v. 4·93 and 5·20 μmol/l) than those with CT and TT genotypes. Folate concentrations were positively associated with fasting plasma glucose (FPG), 1-h plasma glucose (1-h PG), 2-h plasma glucose (2-h PG) and GDM risk. Vitamin B12 levels were negatively correlated with FPG and GDM. Although no direct association was found between MTHFR rs1801133 genotypes and GDM, there were significant indirect effects of MTHFR rs1801133 CC genotype on FPG (β: 0·005; 95 % CI: 0·001, 0·013), 1-h PG (β: 0·006; 95 % CI: 0·001, 0·014), 2-h PG (β: 0·007; 95 % CI: 0·001, 0·015) and GDM (β: 0·006; 95 % CI: 0·001, 0·014) via folate. In conclusion, serum folate mediates the effect of MTHFR rs1801133 on blood glucose levels and GDM. Our findings potentially provide a feasible GDM prevention strategy via individualised folate supplementation according to the MTHFR genotypes.