Objective To evaluate the association between vitamin D levels and polycystic ovarian syndrome (PCOS) by Mendelian randomization (MR) analysis, and assessed the role of obesity in this association. Methods Public genome-wide association studies were used to obtain single nucleotide polymorphism (SNP) data of exposure and outcome. Inverse variance weighting (IVW) was used as the main analysis method to analyze the causal relationship between vitamin D level (including total vitamin D level, serum 25-hydroxyvitamin D level) and vitamin D-binding protein level and polycystic ovary syndrome. In addition, multivariate MR method was used to explore the influence of obesity. Results IVW method showed that 25-hydroxyvitamin D was a protective factor for PCOS (OR=0.185, 95%CI 0.058 to 0.585, P=0.004). There was no interference of heterogeneity and horizontal pleiotropy among the data, and the data tended to be stable in general. The remaining total vitamin D levels and vitamin D-binding protein levels did not show an association with PCOS at the genetic level. MVMR analysis adjusted for obesity and BMI in adolescents showed that 25-hydroxyvitamin D was still negatively associated with the risk of PCOS (OR=3.354, 95%CI 0.150 to 2.270, P=0.025). Conclusion By bidirectional Mendelian randomization analysis, serum 25-hydroxyvitamin D is identified as a protective factor for PCOS, and the increase of serum 25-hydroxyvitamin D level can reduce the risk of PCOS. Obesity does not affect the causal relationship between serum 25-hydroxyvitamin D and PCOS at the genetic level.