Objective To explore the efficacy and mechanism of Shugan huazhi decoction in diabetes mellitus(DM)with metabolic fatty liver disease (MAFLD). Method Zebrafish experiments were used to predict the efficacy of Shugan huazhi decoction. 18 mice were randomly divided into normal control group, model group (DM with MAFLD model), and Shugan huazhi decoction group. The Shugan huazhi decoction group was treated with Shugan huazhi decoction for 4 weeks in DM combined with MAFLD mice. The expression levels of blood glucose(BG), blood lipids, liver function, C-reactive protein (CRP), C-peptide, liver lipopolysaccharide (LPS), reactive oxygen species (ROS), extracellular signal-regulated kinase (ERK), c-Jun N-terminal kinase (JNK), microtubule associated protein 1 light chain 3B (LC3B), P38 mitogen activated protein kinase (P38), autophagy protein P62 (P62), as well as differences in liver pathology, gut microbiota, and metabolomics were compared in each group. DM with MAFLD mice were randomly divided into positive control group and fecal microbiota transplantation group. The positive control group was treated with bifidobacteria, while the fecal microbiota transplantation group was treated with the fecal suspension of Shugan huazhi decoction group. The BG, blood lipid, liver function, LPS, liver pathology and gut microbiota of two groups were detected. Result The result of zebrafish experiment showed that Shugan huazhi decoction has the effect of decreasing blood lipids and BG. After the treatment of Shugan huazhi decoction, the expression levels of BG, blood lipids, liver function, CRP, C-peptide, liver LPS, ERK, JNK, P38 and P62 were decreased, the expression level of liver LC3B was increased, and the liver lipid deposition was improved in DM with MAFLD mice. The gut microbiota was dominated by Firmicutes, Eubacterales, Clostridia, Lachnospiraceae, Oscillibacter, and Pseudoflavonifractor, which were negatively correlated with metabolites monoglycerides, diglycerides, and triglycerides. The result of fecal microbiota transplantation experiment showed that the levels of BG, blood lipids, liver function, and LPS were decreased compared with the positive control group, but there was no statistical difference between the two groups. The relative abundance of Parasottella, Faecalibaculum, Candidatus-Amulumdisruptor, and Bacteroides were increased, while the relative abundance of Escherichia, Lactobacillus, Parabteroides, and Akkermansia were decreased. Conclusion The therapeutic effect of Shugan huazhi decoction in DM with MAFLD may be achieved by multiple pathways and targets, such as regulating the MAPK signaling pathway, autophagy and gut microbiota, improving metabolism, and reducing the levels of LPS and inflammatory factors.