This Mendelian randomization (MR) study aims to explore the relationship between gut microbiota and the occurrence of cholelithiasis, as well as the impact of cholecystectomy on the gut microbiota. This study leverages data on exposures and outcomes from the GWAS database, employing the inverse variance weighting (IVW) method to obtain primary causal estimates. Heterogeneity is assessed using Cochran Q and Rücker Q tests through both IVW and MR-Egger methods. Pleiotropy is evaluated using the Egger-intercept method, while sensitivity analyses are conducted via leave-one-out tests. Additionally, the F-statistic is calculated to assess the presence of weak instrument bias. Finally, the MR-PRESSO method is utilized to validate the findings concerning the relationship between gut microbiota and the incidence of cholelithiasis, as well as the impact of cholecystectomy on gut microbiota composition. The genera Butyricicoccus (ID: 2055), Solibacillus (ID: 11348), Anaerotruncus (ID: 2054), Allisonella (ID: 2174), and Howardella (ID: 2000) have been found to decrease the genetically predicted probability of cholelithiasis. Reverse MR analysis indicates that the occurrence of cholelithiasis reduces the levels of gut microbiota such as Blautia (ID: 1992), Anaerofilum (ID: 2053), Howardella (ID: 2000), Butyricicoccus (ID: 2055), Solibacillus (ID: 11348), Allisonella (ID: 2174), Anaerotruncus (ID: 2054), and Firmicutes (ID: 1672). Additionally, the genera Odoribacter (ID: 952), and Holdemanella (ID: 2157) increase the genetically predicted risk of cholecystectomy. Reverse MR results show that post-cholecystectomy reduces the levels of gut microbiota such as Blautia (ID: 1992), Butyricicoccus (ID: 2055), Alistipes (ID: 11296), Oxalobacteraceae (ID: 2966), and Ruminococcaceae UCG010 (ID: 11367). Conversely, post-cholecystectomy increases the levels of gut microbiota such as Odoribacter (ID: 952), an unknown family (ID: 1000001214), an unknown genus (ID: 1000001215), Aeromonadales (ID: 1591), Holdemanella (ID: 2157), Phascolarctobacteria (ID: 1589), and Eggerthella (ID: 819). All study results show no horizontal pleiotropy, and the MR-PRESSO validation results are consistent with the MR analysis findings. This study elucidates the relationship between gut microbiota and the occurrence of cholelithiasis, as well as the impact of cholecystectomy on the gut microbiota. These findings have clinical significance for diagnosing disease onset and understanding digestive function changes following gallbladder removal, providing theoretical support for further investigation into the molecular mechanisms underlying cholelithiasis.