BackgroundGut microbiota may influence the development of acute pancreatitis (AP), a serious gastrointestinal disease with high morbidity and mortality. This study aimed to identify a causal link by investigating the relationship between gut microbiota and AP.MethodsMendelian randomization (MR) and a nested case–control study were used to explore associations between gut microbiota composition and AP. 16S rRNA sequencing, random forest modelling (RF), support vector machine (SVM), and Kaplan–Meier survival analysis was applied to identify significant gut microbiota and their correlation with hospitalization duration in AP patients.ResultsBidirectional MR results confirmed a causal link between specific gut microbiota and AP (15 and 8 microbial taxa identified via forward and reverse MR, respectively). The 16S rRNA sequencing analysis demonstrated a pronounced difference in gut microbiota composition between cases and controls. Notably, after a comprehensive evaluation of the results of RF and SVM, Bacteroides plebeius (B. plebeius) was found to play a significant role in influencing the hospital status. Using a receiver operating characteristic (ROC) curve, the predictive power (0.757) of B. plebeius. Kaplan–Meier survival analysis offered further insight that patients with an elevated abundance of B. plebeius experienced prolonged hospital stays.ConclusionCombining MR with nested case–control studies provided a detailed characterization of interactions between gut microbiota and AP. B. plebeius was identified as a significant contributor, suggesting its role as both a precursor and consequence of AP dynamics. The findings highlight the multifactorial nature of AP and its complex relationship with the gut microbiota. This study lays the groundwork for future therapeutic interventions targeting microbial dynamics in AP treatment.