BackgroundIt has emerged that disturbances of the gut microbiota (GM) are linked to insomnia. However, the causality of the observed associations remains uncertain.MethodsWe conducted a two-sample Mendelian randomization analysis based on genome-wide association study data to explore the possible causal link between GM and insomnia. The GM data were from the MiBioGen consortium, while the summary statistics of insomnia were obtained from the FinnGen consortium R9 release data. Cochran’s Q statistics were used to analyze instrumental variable heterogeneity.ResultsAccording to the inverse variance weighted estimates, the family Ruminococcaceae (odds ratio = 1.494, 95% confidence interval:1.004–2.223, p = 0.047) and the genus Lachnospiraceae (odds ratio = 1.726, 95% confidence interval: 1.191–2.501, p = 0.004) play a role in insomnia risk. In contrast, the genus Flavonifractor (odds ratio = 0.596, 95% confidence interval: 0.374–0.952, p = 0.030) and the genus Olsenella (odds ratio = 0.808, 95% confidence interval: 0.666–0.980, p = 0.031) tended to protect against insomnia. According to the reverse MR analysis, insomnia can also alter GM composition. Instrumental variables were neither heterogeneous nor horizontal pleiotropic.ConclusionIn conclusion, our Mendelian randomization study provides evidence of a causal relationship between GM and insomnia. The identified GM may be promising gut biomarkers and new therapeutic targets for insomnia. This investigation also provides a foundation for future studies examining the influence of GM on sleep disorders beyond insomnia, with potential implications for redefining the mechanisms governing sleep regulation.