Background: Erectile dysfunction (ED), as one of the most prevalent consequences in male diabetic patients, has a serious impact on men's physical and mental health, and the treatment effect of diabetic mellitus erectile dysfunction (DMED) is often worse. Therefore, the development of a novel therapeutic approach is urgent. As stem cells with high differentiation potential, human umbilical cord mesenchymal stem cells (HUCMSCs) have been widely used in the treatment of diseases in other systems, and are expected to be a promising strategy for the treatment of DMED. In this study, we investigated the role of HUCMSCs in managing erectile function in rat models of type 1 diabetes mellitus (T1DM) and type 2 diabetes mellitus (T2DM) and compared the effects of two different injection methods.Methods: T1DM and T2DM ED rats were given labelled HUCMSCs by corpus cavernosum injection and tail vein injection, respectively. ICP and MAP were monitored simultaneously by electrical stimulation four weeks after injection to indicate the erectile function of rats. To track the development and colonisation capabilities of stem cells, we performed EdU assay with penile tissue. The histological changes of the penis were observed by hematoxylin-eosin staining, and Masson’s trichrome staining was conducted to evaluate the smooth muscle content and the degree of fibrosis in the rat penis. Then, we employed specific kits to measure the level of NO, cGMP, MDA, SOD and Fe in penis. Electron transmission microscopy was implemented to observe morphology of mitochondria. Besides, western blot and immunofluorescence staining were performed to demonstrate the expression of ferroptosis-related genes.Results: We found that HUCMSCs improved erectile function in T1DM and T2DM ED rats, with no difference in efficacy between corpus cavernosum injection and tail vein injection. The EdU assay revealed that only a tiny percentage of HUCMSCs colonized the corpus cavernosum, while smooth muscle in the penis expanded and collagen decreased following HUCMSC injection. Moreover, the levels of oxidative stress in the penis of the rats given HUCMSCs were dramatically reduced, as was the tissue iron content. HUCMSCs normalized mitochondrial morphology within corpus cavernosum smooth muscle cells (CCSMCs), which were characteristically altered by high glucose. Furthermore, the expression of ferroptosis inhibitory genes SLC7A11 and GPX4 was obviously elevated in CCSMCs after stem cell management, but the abundances of ACSL4, LPCAT3 and ALOX15 showed the polar opposite tendency.Conclusions: HUCMSCs can effectively and safely alleviate erectile dysfunction in T1DM and T2DM ED rats, while restoring erectile function by attenuating diabetes-induced ferroptosis in CCSMCs. Additionally, this study provides significant evidence for the development of HUCMSCs as a viable therapeutic strategy for DMED.