Ferroptosis of neurons is a significant cause of brain injury following intracerebral hemorrhage (ICH). As an iron-containing compound in hemoglobin, heme contributes to nerve injury post-ICH. Melatonin has been shown to mitigate the effects of ICH, yet its specific functions remain largely elusive. In this study, we aimed to explore the roles and mechanisms of melatonin in heme-induced ferroptosis subsequent to ICH. C57BL/6 mice were intracranially injected with heme and then treated with melatonin. Behavior tests [modified neurological severity score (mNSS), forelimb placing, and corner turn tests], H&E staining, Nissl staining, and Prussian blue staining were used to evaluate mouse brain tissue injury. In vitro, HT-22 cells were stimulated with heme and cell viability was determined by crystal violet staining. The iron contents were determined in heme-treated brains and cells, and the levels of 4-hydroxynonenal (4-HNE) and malonaldehyde (MDA) were assessed by ELISA. Reverse transcription-quantitative polymerase chain reaction (RT-qPCR) was used to investigate the mRNA levels of nuclear factor erythroid 2-related factor 2 (Nrf2) and heme oxygenase-1 (HO-1). Immunoblotting was used to analyze the protein expression of glutathione peroxidase 4 (GPX4), solute carrier family 7 member 11 (SLC7A11), Nrf2, and HO-1. Finally, small interfering RNA (siRNA) was used to knock down Nrf2 in HT-22 cells. Melatonin treatment alleviated heme-induced injuries to neural function, as indicated by improved behavior in the mice. Moreover, melatonin decreased cell death and iron concentrations, increased MDA and 4-HNE levels, and reversed the decreases in GPX4, SLC7A11, Nrf2, and HO-1 induced by heme in vitro and in vivo. These results indicated that melatonin could improve the ferroptosis induced by heme. In addition, we found that Nrf2 knockdown attenuated the therapeutic effect of melatonin on neuronal ferroptosis induced by heme. In general, melatonin alleviates heme-induced ferroptosis by activating the Nrf2/HO-1 pathway, which implies that melatonin is a promising treatment for ferroptosis in ICH.