Abstract Osteoporosis is a common systemic bone disorder characterized by bone loss and an increased risk of fracture. Melatonin has powerful antioxidant and anti-aging functions and has been proposed as a treatment for osteoporosis; however, the therapeutic effect of this agent needs further validation and the mechanisms remain to be explored. In this study, we observed that melatonin markedly stimulated osteogenic differentiation in vitro and alleviated osteoporosis symptoms in mice. After melatonin treatment, thioredoxin1 (TRX1) was upregulated under both in vivo and in vitro conditions, while its expression notably decreased in osteoporotic mice, thereby suggesting this gene possibly mediated the therapeutic effect of melatonin on osteoporosis. Moreover, the following overexpression or silencing of TRX1 proved its ability to induce osteogenesis of bone marrow mesenchymal stem cells (BMSCs). Furthermore, osteogenic differentiation and osteoporosis after melatonin pretreatment was attenuated both in BMSCs and in mice with TRX1 knockdown. These findings confirm that TRX1 is potentially associated with the beneficial effects of melatonin and that the use of melatonin may reduce osteoporosis. Overall, melatonin treatment induced expression of TRX1, and the up-regulated gene enhanced osteogenic differentiation and eventually reduced bone loss in osteoporosis. The results indicate that TRX1 may be a target of osteoporosis therapy.