Peritoneal fibrosis (PF) is one of the most serious complications of peritoneal dialysis (PD) and is the greatest obstacle to the clinical application of PD. Chinese herbal monomers have been effective in the prevention and treatment of PF. The aim of this study was to observe the effect of allicin on PF in rats induced by high glucose and to investigate its molecular mechanism of action. A rat model of PF was established by using a 4.25% glucose-based standard peritoneal dialysis solution. The degree of peritoneal pathological damage was assessed by Hematoxylin and eosin (H&E) staining. Peritoneal collagen deposition was detected by Masson's trichrome staining. The levels of Interleukin-6 (IL-6), Tumor necrosis factor-α (TNF-α), Interleukin-1β (IL-1β) and monocyte chemoattractant protein-1 (MCP-1) in the serum were measured by Enzyme Linked Immunosorbent Assay (ELISA). The expression levels of TGF-β, α-smooth muscle actin (α-SMA) and collagen I were examined by western blotting and immunohistochemistry. The protein expression levels and mRNA levels of E-cadherin, N-cadherin, vimentin, janus kinase 2 (JAK2) and signal transducer and activator of transcription 3 (STAT3) in peritoneal tissue were determined by western blotting and qRT-PCR. TGF-β1 stimulated human peritoneal mesothelial cells (HPMCs), and the cells were treated with allicin and the JAK2/STAT3 pathway activator colivelin alone or in combination. A cell counting kit-8 (CCK-8) assay was used to measure cell viability. The role of JAK2/STAT3 in the effects of allicin was confirmed via in vitro mechanistic research by western blotting, wound healing assays and Transwell assays. Allicin relieves the inflammatory response by downregulating the levels of IL-1β, IL-6, MCP-1 and TNF-α. Furthermore, allicin decreased the expression of TGF-β, α-SMA and collagen I. Allicin also alleviated epithelial-to-mesenchymal transition (EMT), as specifically manifested by increased E-cadherin and reduced N-cadherin and vimentin. Further studies revealed that allicin reduced the protein levels of JAK2, STAT3, p-JAK2, and p-STAT3. The results of the cellular experiments verified the above results. The ability of allicin to inhibit fibrosis and the EMT process was significantly attenuated after HPMCs were treated with colivelin. Taken together, these findings suggest that allicin inhibits inflammation and EMT, thereby improving PF, and this protective effect may be achieved by inhibiting the JAK2/STAT3 signaling pathway.