Objective To explore the association of clinical and subclinical bacterial vaginosis before conception with the risk of spontaneous abortion. Design Retrospective cohort study. Setting Mainland China. Population This study included women who enrolled in and completed the National Free Pre-Pregnancy Checkups Project between January 1, 2014 and December 31, 2018. Methods Clinical bacterial vaginosis before conception was diagnosed according to the Amsel criteria, and subclinical bacterial vaginosis before conception was defined as any indicators in the Amsel Criteria being positive but not meeting the diagnostic criteria. Analyses were performed by multivaribale-adjusted logistic models with crude and multivaribale-adjusted odds ratios including 95% confidence interval. Main outcome measures Spontaneous abortion was defined as fetal death occurring spontaneously before the 28th week of gestation. Results Of the included participants, 0.27% and 6.97% of them had clinical and subclinical bacterial vaginosis before conception respectively. A significantly increased risk of spontaneous abortion was observed for women with preconception bacterial vaginosis (OR: 1.19, 95% CI: 1.06-1.34). After excluding participants with preconception bacterial vaginosis, subclinical bacterial vaginosis was associated with a 15% (13%-18%) increased risk of spontaneous abortion. And the corresponding multivariable-adjusted ORs of exposure to abnormal vaginal discharge characteristics, vaginal pH value ≥4.5, positive clue cell test, and positive Whiff test for spontaneous abortion were 1.20 (1.03-1.39), 1.15 (1.12-1.18), 1.08 (0.97-1.19), and 1.24 (1.11-1.38). Conclusion Both clinical and subclinical bacterial vaginosis before conception were prospectively associated with an increased risk of spontaneous abortion.