The interaction between intestinal microbiota and infertility is less researched. This study was performed to investigate the causal association between gut microbiota and infertility. In this two-sample Mendelian randomization (MR) study, genetic variants of intestinal microbiota were obtained from the MiBioGen consortium, which included 18,340 individuals. Inverse variance weighting (IVW), MR-Egger, weighted median, maximum likelihood, MR Robust adjusted profile score, MR Pleiotropy residual sum, and outlier (MR-PRESSO) methods were used to explore the causal links between intestinal microbiota and infertility. The MR-Egger intercept term and the global test from the MR-PRESSO estimator were used to assess the horizontal pleiotropy. The Cochran Q test was applied to evaluate the heterogeneity of instrumental variables (IVs). As indicated by the IVW estimator, significantly protective effects of the Family XIII AD3011 group (OR = 0.87) and Ruminococcaceae NK4A214 group (OR = 0.85) were identified for female fertility, while Betaproteobacteria (OR = 1.18), Burkholderiales (OR = 1.18), Candidatus Soleaferrea (OR = 1.12), and Lentisphaerae (OR = 1.11) showed adverse effects on female fertility. Meanwhile, Bacteroidaceae (OR = 0.57), Bacteroides (OR = 0.57), and Ruminococcaceae NK4A214 group (OR = 0.61) revealed protective effects on male fertility, and a causal association between Anaerotruncus (OR = 1.81) and male infertility was detected. The effect sizes and directions remained consistent in the other five methods except for Candidatus Soleaferrea. No heterogeneity or pleiotropy were identified by Cochran's Q test, MR-Egger, and global test (all p > 0.05). This two-sample MR study revealed that genetically proxied intestinal microbiota had potentially causal effects on infertility. In all, the Ruminococcaceae NK4A214 group displayed protective effects against both male and female infertility. Further investigations are needed to establish the biological mechanisms linking gut microbiota and infertility.