Shaofu Zhuyu decoction has been widely used to treat gynecological diseases; however, its mechanism of action in endometriosis remains unclear. We analyzed Shaofu Zhuyu decoction’s chemical composition using ultra-high performance liquid chromatography-mass spectrometry. In an endometriosis mouse model, ectopic lesions weight measurements and hematoxylin and eosin staining were used to assess the therapeutic efficacy of Shaofu Zhuyu decoction. Effects on intestinal microflora were analyzed using 16S ribosomal ribonucleic acid sequencing, and impacts on focal fibrosis were analyzed using Masson’s trichrome staining. Moreover, fibrosis- and metabolism-related proteins were assessed using immunohistochemistry and enzyme-linked immunosorbent assay. The study identified 157 chemical constituents within Shaofu Zhuyu decoction. Shaofu Zhuyu decoction treatment in mice with endometriosis resulted in a reduction in ectopic lesions weight (P<0.05) and delayed disease progression. Moreover, it improved the diversity and abundance of intestinal flora, and decreased the expression of Lachnospiraceae (P<0.05), Rikenellaceae (P<0.01), Ruminococcaceae (P<0.01), Lachnoclostridium (P<0.05), and unclassified_f__Ruminococcaceae (P<0.05). Kyoto Encyclopedia of Genes and Genomes analysis revealed enrichment in carbohydrate, amino acid, and lipid metabolism pathways. Masson’s trichrome staining revealed that compared to the untreated group, the Shaofu Zhuyu decoction group exhibited significantly reduced collagen deposition areas (P<0.001), lower TGF-β1 (P<0.001), COL1A1 (P<0.05), and α-SMA (P<0.01) expression in ectopic lesions, along with increased serum adiponectin (P<0.05), decreased serum leptin (P<0.05), TGF-β1 (P<0.001), and CTGF (P<0.05). Shaofu Zhuyu decoction regulates the intestinal flora of mice with endometriosis while also reducing fibrosis at the lesion site. These findings highlight novel mechanisms for its efficacy in alleviating endometriosis.