Objective: We previously reported that cadmium (Cd) inhibits osteogenic differentiation of bone marrow mesenchymal stem cells (BMSCs). In addition, gallic acid (GA) improves BMSC differentiation. Here, we aim to study the ability of GA to prevent osteogenic inhibition induced by Cd. Materials and Methods: In this experimental study, BMSCs were extracted and purified from Wistar rats and their viability was determined in the presence of Cd and GA. The results indicated that 1.5 μM Cd and 0.25 μM of GA were appropriate for further investigation. After 20 days in osteogenic medium, matrix production was analysed by alizarin red, calcium content, and alkaline phosphatase (ALP) activity. Osteogenic-related genes and collagen 1A1 (COL1A1) protein expressions were investigated. The preventive effect of GA on oxidative stress and metabolic change induced by Cd was estimated. Results: GA counteracted the inhibitory effect of Cd on matrix production and significantly (P=0.0001) improved the osteogenic differentiation ability of BMSCs. Also, GA prevented the toxic effect of Cd on osteogenic-related gene expressions and nullified the reducing effect of Cd on COL1Al and ALP activity. A significant reduction (P=0.0001) in malondialdehyde and lactic acid concentration showed that GA counteracted both oxidative stress and metabolic changes caused by Cd. Conclusion: GA prevented the toxic effect of Cd, an environmental pollutant and a factor in osteoporosis.