To investigate the effects of melatonin (MT) on bone mass and serum inflammatory factors in rats received ovariectomy (OVX) and to investigate the effects of MT on the levels of inflammatory factors in culture medium and osteogenic ability of bone marrow mesenchymal stem cells (BMSCs) stimulated by lipopolysaccharide. Fifteen 12-week-old Sprague Dawley (SD) rats were randomly divided into 3 groups. The rats in Sham group only received bilateral lateral abdominal incision and suture, the rats in OVX group received bilateral OVX, and the rats in OVX+MT group received 100 mg/(kg·d) MT oral intervention after bilateral OVX. After 8 weeks, the levels of serum inflammatory factors [interleukin-1β (IL-1β), IL-6, and tumor necrosis factor α (TNF-α)] were detected using ELISA assay. Besides, the distal femurs were detected by Micro-CT to observe changes in bone mass and microstructure, and quantitatively measured bone volume fraction, trabecular thickness, and trabecular number. The BMSCs were extracted from the femurs of three 3-week-old SD rats using whole bone marrow culture method and passaged. The 3rd-5th passage BMSCs were cultured with different concentrations of MT (0, 1, 10, 100, 1 000 µmol/L), and the cell viability was then detected using cell counting kit 8 (CCK-8) to select the optimal concentration of MT for subsequent experiments. Cells were devided into osteogenic induction group (group A) and osteogenic induction+1/5/10 μg/mL lipopolysaccharide group (group B-D). The levels of inflammatory factors (IL-1β, IL-6 and TNF-α) in cell culture medium were detected using ELISA assay after corresponding intervention. According to the results of CCK-8 method and ELISA detection, the cells were intervened with the most significant concentration of lipopolysaccharide for stimulating inflammation and the optimal concentration of MT with osteogenic induction, defining as group E, and the cell culture medium was collected to detect the levels of inflammatory factors by ELISA assay. After that, alkaline phosphatase (ALP) staining and alizarin red staining were performed respectively in groups A, D, and E, and the expression levels of osteogenic related genes [collagen type Ⅰ alpha 1 chain (Col1a1) and RUNX family transcription factor 2 (Runx2)] were also detected by real time fluorescence quantitative PCR (RT-qPCR). ELISA and Micro-CT assays showed that compared with Sham group, the bone mass of the rats in the OVX group significantly decreased, and the expression levels of serum inflammatory factors (IL-1β, IL-6, and TNF-α) in OVX group significantly increased (P<0.05). Significantly, the above indicators in OVX+MT group were all improved (P<0.05). Rat BMSCs were successfully extracted, and CCK-8 assay showed that 100 µmol/L was the maximum concentration of MT that did not cause a decrease in cell viability, and it was used in subsequent experiments. ELISA assays showed that compared with group A, the expression levels of inflammatory factors (IL-1β, IL-6, and TNF-α) in the cell culture medium of groups B-D were significantly increased after lipopolysaccharide stimulation (P<0.05), and in a concentration-dependent manner. Moreover, the expression levels of inflammatory factors in group D were significantly higher than those in groups B and C (P<0.05). After MT intervention, the expression levels of inflammatory factors in group E were significantly lower than those in group D (P<0.05). ALP staining, alizarin red staining, and RT-qPCR assays showed that compared with group A, the percentage of positive area of ALP and alizarin red and the relative mRNA expressions of Col1a1 and Runx2 in group D significantly decreased, while the above indicators in group E significantly improved after MT intervention (P<0.05). MT may affect the bone mass of postmenopausal osteoporosis by reducing inflammation in rats; MT can reduce the inflammation of BMSCs stimulated by lipopolysaccharide and weaken its inhibition of osteogenic differentiation of BMSCs.