Gestational diabetes mellitus, a heritable metabolic disorder and the most common pregnancy-related condition, remains understudied regarding its genetic architecture and its potential for early prediction using genetic data. Here we conducted genome-wide association studies on 116,144 Chinese pregnancies, leveraging their non-invasive prenatal test sequencing data and detailed prenatal records. We identified 13 novel loci for gestational diabetes mellitus and 111 for five glycemic traits, with minor allele frequencies of 0.01-0.5 and absolute effect sizes of 0.03-0.62. Approximately 50% of these loci were specific to gestational diabetes mellitus and gestational glycemic levels, distinct from type 2 diabetes and general glycemic levels in East Asians. A machine learning model integrating polygenic risk scores and prenatal records predicted gestational diabetes mellitus before 20 weeks of gestation, achieving an area under the receiver operating characteristic curve of 0.729 and an accuracy of 0.835. Shapley values highlighted polygenic risk scores as key contributors. This model offers a cost-effective strategy for early gestational diabetes mellitus prediction using clinical non-invasive prenatal test.