Several observational studies have suggested that proton-pump inhibitor (PPI) use might increase diabetes risk, but the mechanism remains unclear. This study aimed to investigate the effects of PPI use on gut microbiota and bile acids (BAs) profiles, and to explore whether these changes could mediate the association of PPIs use with fasting blood glucose (FBG) levels and insulin resistance (IR) in Chinese population. A cross-sectional study was conducted in Shenzhen, China, from April to August 2021, enrolled 200 eligible patients from the local hospital. Participants completed a questionnaire and provided blood and stool samples. Gut microbiome was measured by16S rRNA gene sequencing, and bile acidswere quantified by UPLC-MS/MS. Insulin resistance (IR) was assessed using the Homeostasis Model Assessment 2 (HOMA2-IR). PPI use was positively associated with higher levels of FBG and HOMA2-IR after controlling for possible confounders. PPI users exhibited a decreased Firmicutes and an increase in Bacteroidetes phylum, alongside higher levels of glycoursodeoxycholic acid (GUDCA) and taurochenodeoxycholic acid (TCDCA). Higher abundances of Bacteroidetes and Fusobacterium as well as higher levels of TCDCA in PPI users were positively associated with elevated FBG or HOMA2-IR. Mediation analyses indicated that the elevated levels of FBG and HOMA2-IR with PPI use were partially mediated by the alterations in gut microbiota and specific BAs (i.e., Fusobacterium genera and TCDCA). Long-term PPI use may increase FBG and HOMA2-IR levels, and alterations in gut microbiota and BAs profiles may partially explain this association.