Failure to predict and understand the causes of preterm birth, the leading cause of neonatal morbidity and mortality, have limited effective interventions and therapeutics. From a cohort of 2000 pregnant women, we performed a nested case control study on 107 well-phenotyped cases of spontaneous preterm birth (sPTB) and 432 women delivering at term. Using innovative Bayesian modeling of cervicovaginal microbiota, seven bacterial taxa were significantly associated with increased risk of sPTB, with a stronger effect in African American women. However, higher vaginal levels of β-defensin-2 lowered the risk of sPTB associated with cervicovaginal microbiota in an ethnicity-dependent manner. Surprisingly, even in Lactobacillus spp. dominated cervicovaginal microbiota, low β-defensin-2 was associated with increased risk of sPTB. These findings hold promise for diagnostics to accurately identify women at risk for sPTB early in pregnancy. Therapeutic strategies could include immune modulators and microbiome-based therapeutics to reduce this significant health burden.