Although heterotopic ossification (HO) has been reported to be a common complication of the posttraumatic healing process, the underlying mechanism remains unknown. Endothelial-mesenchymal transition (EndMT) is known to play a role in HO, and our recent study observed that neuroendocrine signals can promote HO by modulating EndMT. Melatonin, a neuroendocrine hormone secreted mainly by the pineal gland, has been documented to perform its function in the skeletal system. This study aimed at describing the expression of melatonin during the formation of HO in rat models of Achilles tendon injury and to further investigate its role in regulating EndMT in HO. Histological staining revealed the expression of melatonin throughout the formation of heterotopic bone in injured Achilles tendons, and the serum melatonin levels were increased after the initial injury. Double immunofluorescence showed that the MT2 melatonin receptor was notably expressed at the sites of injury. Micro-CT showed the enhancement of heterotopic bone volume and calcified areas in rats treated with melatonin. Additionally, our data showed that melatonin induced EndMT in primary rat aortic endothelial cells (RAOECs), which acquired traits including migratory function, invasive function and EndMT and MSC marker gene and protein expression. Furthermore, our data exhibited that melatonin promoted the osteogenic differentiation of RAOECs undergoing EndMT in vitro. Importantly, inhibition of the melatonin-MT2 pathway by using the MT2 selective inhibitor 4-P-PDOT inhibited melatonin-induced EndMT and osteogenesis both in vivo and in vitro. In conclusion, these findings demonstrated that melatonin promoted HO through the regulation of EndMT in injured Achilles tendons in rats, and these findings might provide additional directions for the management of HO.