Large numbers of elderly people have aging-associated osteoporosis, but efficient approaches to ameliorate bone loss are limited due to our poor understanding of the underlying mechanisms. In this study, we found that melatonin levels in bone marrow decreased with age, and melatonin primarily enhanced the osteogenic potential of mesenchymal stem cells (MSCs) derived from elderly donors compared with fetal- or young adult-derived MSCs. Mechanistic studies indicated melatonin treatment alleviated the senescence-related hypermethylation of the MMSET promoter, leading to elevated expression of the histone methyltransferase NSD2, and promoted the histone H3 dimethylation modification at lysine 36 of the osteogenic genes RUNX2 and SP7/OSTERIX as a consequence. MMSET depletion partially abolished the effects of melatonin on osteogenesis in senescent MSCs in vitro. Moreover, melatonin treatment promoted bone formation and alleviated the progression of osteoporosis in a mouse model of aging. Clinically, severity of senile osteoporosis (SOP) in patients was associated with melatonin levels in bone marrow plasma and the MMSET expression in MSCs, and melatonin treatment enhanced osteoblastogenesis from MSCs derived from SOP patients. Our study discovered a previously unreported epigenetic regulatory role for melatonin in alleviating MSC senescence and suggests that melatonin may be a potent agent for preventing aging-associated osteoporosis.