The effects of SGLT2 inhibitors on hepatic fibrosis in diabetes remain unclear. This study aimed to investigate the effects of empagliflozin on liver fibrosis in high‐fat diet/streptozotocin‐induced mice and the correlation with gut microbiota. After the application of empagliflozin for 6 weeks, we performed oral glucose tolerance and intraperitoneal insulin tolerance tests to assess glucose tolerance and insulin resistance, and stained liver sections to evaluate histochemical and hepatic pathological markers of liver fibrosis. Moreover, 16S rRNA amplicon sequencing was performed on stool samples to explore changes in the composition of intestinal bacteria. We finally analysed the correlation between gut microbiome and liver fibrosis scores or indicators of glucose metabolism. The results showed that empagliflozin intervention improved glucose metabolism and liver function with reduced liver fibrosis, which might be related to changes in intestinal microbiota. In addition, the abundance of intestinal probiotic Lactobacillus increased, while Ruminococcus and Adlercreutzia decreased after empagliflozin treatment, and correlation analysis showed that the changes in microbiota were positively correlated with liver fibrosis and glucose metabolism. Overall, considering the contribution of the gut microbiota in metabolism, empagliflozin might have improved the beneficial balance of intestinal bacteria composition. The present study provides evidence and indicates the involvement of the gut–liver axis by SGLT2 inhibitors in T2DM with liver fibrosis.