Intrauterine adhesions (IUA) are a common gynecological problem. Stem cell therapy has been widely used in the treatment of IUA. However, due to the complex and harsh microenvironment of the uterine cavity, the effectiveness of such therapy is greatly inhibited. This study aimed to investigate whether melatonin pretreatment enhances the efficacy of human umbilical cord mesenchymal stem cells (HucMSCs) in IUA treatment in rats. First, we explored the effect of melatonin on the biological activity of HucMSCs in vitro through a macrophage co-culture system, CCK-8, EdU, flow cytometry, immunofluorescence staining, and qRT-PCR. Subsequently, we established the IUA rat model and tracked the distribution of HucMSCs in this model. In addition, we observed the number of M1 and M2 macrophages through immunofluorescence staining and detected the levels of inflammatory cytokines. Four weeks after cell transplantation, HE, Masson, and immunohistochemical staining were performed. In vitro experiments showed that melatonin pretreatment of HucMSCs promoted proliferation, reduced apoptosis, up-regulated the stemness gene, and regulated macrophage polarization. In vivo, melatonin pretreatment caused more HucMSCs to remain in the uterine cavity. Melatonin-pretreated HucMSCs recruited more macrophages, regulated macrophage polarization, and reduced inflammation. Melatonin-pretreated HucMSCs relieved fibrosis, increased endometrium thickness, and upregulated CD34, vimentin, PCNA, and α-SMA expression. Fertility tests showed that melatonin-pretreated HucMSCs increased the number of embryos. In summary, pretreatment with melatonin was beneficial for HucMSC treatment because it enhanced the cell’s ability to recruit macrophages and regulate macrophage polarization, which led to the regeneration of the endometrium and improved pregnancy outcomes.