To identify and internally validate metabolites predictive of spontaneous preterm birth (sPTB) using multiple machine learning methods and sequential maternal serum samples, and to predict spontaneous early term birth (sETB) using these metabolites. Case-cohort design within a prospective cohort study. Cambridge, UK. A total of 399 Pregnancy Outcome Prediction study participants, including 98 cases of sPTB. An untargeted metabolomic analysis of maternal serum samples at 12, 20, 28 and 36 weeks of gestation was performed. We applied six supervised machine learning methods and a weighted Cox model to measurements at 28 weeks of gestation and sPTB, followed by feature selection. We used logistic regression with elastic net penalty, followed by best subset selection, to reduce the number of predictive metabolites further. We applied coefficients from the chosen models to measurements from different gestational ages to predict sPTB and sETB. sPTB and sETB. We identified 47 metabolites, mostly lipids, as important predictors of sPTB by two or more methods and 22 were identified by three or more methods. The best 4-predictor model had an optimism-corrected area under the receiver operating characteristics curve (AUC) of 0.703 at 28 weeks of gestation. The model also predicted sPTB in 12-week samples (0.606, 95% CI 0.544-0.667) and 20-week samples (0.657, 95% CI 0.597-0.717) and it predicted sETB in 36-week samples (0.727, 95% CI 0.606-0.849). A lysolipid, 1-palmitoleoyl-GPE (16:1)*, was the strongest predictor of sPTB at 12 weeks of gestation (0.609, 95% CI 0.548-0.670), 20 weeks (0.630, 95% CI 0.569-0.690) and 28 weeks (0.660, 95% CI 0.599-0.722), and of sETB at 36 weeks (0.739, 95% CI 0.618-0.860). We identified and internally validated maternal serum metabolites predictive of sPTB. A lysolipid, 1-palmitoleoyl-GPE (16:1)*, is a novel predictor of sPTB and sETB. Further validation in external populations is required.