The aim of the present study was to investigate the effect of glucocorticoids in osteoblasts and to examine the role of β‑ecdysterone in the pathogenesis of glucocorticoid‑induced osteoporosis. Osteoblasts were induced from bone marrow mesenchymal stem cells, which were isolated from C57BL/6 mice. Cell viability and apoptosis of osteoblasts were measured by Cell Counting Kit‑8 and flow cytometry analysis, respectively. The expression of related genes and proteins was measured by reverse transcription quantitative polymerase chain reaction and western blot analysis respectively. Dose‑dependent decreases in the cell proliferation and differentiation were observed in dexamethasone (Dex)‑treated osteoblasts, evidenced by downregulation in the activity of alkaline phosphatasedecreased expression levels of Runt‑related transcription factor 2 and osteocalcin, and upregulated expression of RANK ligand. Dex also induced apoptosis and inhibited autophagy of osteoblasts, evidenced by upregulated B‑cell lymphoma 2 (Bcl‑2)‑associated X protein/Bcl‑2 ratio and the activation of mammalian target of rapamycin (mTOR), and decreased expression levels of Beclin‑1, autophagy protein 5 and microtubule‑associated protein 1 light chain 3 II. The effects on cell proliferation, apoptosis and autophagy induced by Dex were reversed by β‑ecdysterone in a dose‑dependent manner. Therefore, β‑ecdysterone may be a promising candidate drug for the treatment of osteoporosis through inducing osteoblast autophagic activity by inactivating mTOR.