Gestational diabetes mellitus (GDM) is a hyperglycemic state that is typically diagnosed by an oral glucose tolerance test (OGTT), which is unpleasant, time-consuming, has low reproducibility, and results are tardy. The machine learning (ML) predictive models that have been proposed to improve GDM diagnosis are usually based on instrumental methods that take hours to produce a result. Near-infrared (NIR) spectroscopy is a simple, fast, and low-cost analytical technique that has never been assessed for the prediction of GDM. This study aims to develop ML predictive models for GDM based on NIR spectroscopy, and to evaluate their potential as early detection or alternative screening tools according to their predictive power and duration of analysis. Serum samples from the first trimester (before GDM diagnosis) and the second trimester (at the time of GDM diagnosis) of pregnancy were analyzed by NIR spectroscopy. Four spectral ranges were considered, and 80 mathematical pretreatments were tested for each. NIR data-based models were built with single- and multi-block ML techniques. Every model was subjected to double cross-validation. The best models for first and second trimester achieved areas under the receiver operating characteristic curve of 0.5768 ± 0.0635 and 0.8836 ± 0.0259, respectively. This is the first study reporting NIR-spectroscopy-based methods for the prediction of GDM. The developed methods allow for prediction of GDM from 10 µL of serum in only 32 min. They are simple, fast, and have a great potential for application in clinical practice, especially as alternative screening tools to the OGTT for GDM diagnosis.