To explore the neuroprotective effects and its possible mechanisms of melatonin (MT) on erectile dysfunction in streptozotocin-induced diabetic rats. Twenty-eight Sprague-Dawley rats received intraperitoneal injection of streptozotocin and 8weeks later, the determined diabetic rats randomly got intraperitoneal injection of phosphate buffer solution (PBS) or MT. Another 12 normal rats received PBS treatment. Four weeks later, intracavernous pressure, mean arterial pressure, pathological changes in penis, and major pelvic ganglion (MPG) were measured. Malondialdehyde, superoxide dismutase, p38 and p-p38 levels in penis were detected. Diabetic rats showed significant decreases of erectile function accompanied with serious neuropathy in dorsal penile nerve (DPN) and MPG, meanwhile collagen deposition, oxidative stress, and p-p38 levels in penis were elevated. Melatonin treatment partially but significantly improved the erectile function, ameliorated neuropathy in DPN and MPG, and decreased collagen deposition, oxidative stress, and p-p38 levels in diabetic rats. Melatonin treatment helps improve erectile function and ameliorate neuropathy and fibrosis in diabetic rats. These may be associated with reductions in oxidative stress, p38MAPK signaling pathway, and neuropathy.