Mechanical unloading leads to bone loss and disuse osteoporosis partly due to impaired osteoblastogenesis of bone marrow stromal cells (BMSCs). However, the underlying molecular mechanisms of this phenomenon are not fully understood. In this study, we demonstrated that cyclic mechanical stretch (CMS) promotes osteoblastogenesis of BMSCs both in vivo and in vitro. Besides, we found that Hedgehog (Hh) signaling pathway was activated in this process. Inhibition of which by either knockdown of Sonic hedgehog (Shh) or treating BMSCs with Hh inhibitors attenuated the osteogenic effect of CMS on BMSCs, suggesting that Hh signaling pathway acts as an endogenous mediator of mechanical stimuli on BMSCs. Furthermore, we demonstrated that Shh expression level was regulated by DNA methylation mechanism. Chromatin Immunoprecipitation (ChIP) assay showed that DNA methyltransferase 3b (Dnmt3b) binds to Shh gene promoter, leading to DNA hypermethylation in mechanical unloading BMSCs. However, mechanical stimulation down-regulates the protein level of Dnmt3b, results in DNA demethylation and Shh expression. More importantly, we found that inhibition of Dnmt3b partly rescued bone loss in HU mice by mechanical unloading. Our results demonstrate, for the first time, that mechanical stimulation regulates osteoblastic genes expression via direct regulation of Dnmt3b, and the therapeutic inhibition of Dnmt3b may be an efficient strategy for enhancing bone formation under mechanical unloading.