Pi-Dan-Jian-Qing decoction (PDJQ) can been used in the treatment of type 2 diabetes mellitus (T2DM) in clinic. However, the protective mechanisms of PDJQ on T2DM remain unknown. Recent studies have shown that the changes in gut microbiota could affect the host metabolism and contribute to progression of T2DM. In this study, we first investigated the therapeutic effects of PDJQ on T2DM rats. 16S rRNA sequencing and untargeted metabolomics analyses were used to investigate the mechanisms of action of PDJQ in the treatment of T2DM. Our results showed that PDJQ treatment could improve the hyperglycemia, hyperlipidemia, insulin resistance (IR) and pathological changes of liver, pancreas, kidney, and colon in T2DM rats. PDJQ could also decrease the levels of pro-inflammatory cytokines and inhibit the oxidative stress. 16S rRNA sequencing showed that PDJQ could decrease the Firmicutes/Bacteroidetes (F to B) ratio at the phylum level. At the genus level, PDJQ could increase the relative abundances of Lactobacillus, Blautia, Bacteroides, Desulfovibrio and Akkermansia and decrease the relative abundance of Prevotella. Serum untargeted metabolomics analysis showed that PDJQ could regulate tryptophan metabolism, histidine metabolism, tricarboxylic acid (TCA) cycle, phenylalanine, tyrosine and tryptophan biosynthesis and tyrosine metabolism pathways. Correlation analysis indicated that the modulatory effects of PDJQ on the tryptophan metabolism, histidine metabolism and TCA cycle pathways were related to alterations in the abundance of Lactobacillus, Bacteroides and Akkermansia. In conclusion, our study revealed the various ameliorative effects of PDJQ on T2DM, including improving the liver and kidney functions and alleviating the hyperglycemia, hyperlipidemia, IR, pathological changes, oxidative stress and inflammatory response. The mechanisms of PDJQ on T2DM are likely linked to an improvement in the dysbiosis of gut microbiota and modulation of tryptophan metabolism, histamine metabolism, and the TCA cycle.