Magnesium (Mg2+) ions are frequently reported to regulate osteogenic activities of mesenchymal stem cells (MSCs). In this study, we propose a numerical model to study the regulatory importance of Mg2+ ions on MSCs osteoblastic differentiation in the presence of an inflammatory response. A fuzzy logic controller was formulated to receive the concentrations of Mg2+ ions and the inflammatory cytokines of TNF-α, IL-10, IL-1β, and IL-8 as cellular inputs and predict the cells' early and late differentiation rates. Five sets of empirical data obtained from published cell culture experiments were used to calibrate the model. The model successfully reproduced the empirical data regarding the concentration- and phase-dependent effect of Mg2+ ions on the differentiation process. In agreement with the experiments, the model showed the stimulatory role of Mg2+ ions on the early differentiation phase, once administered at low concentration, and their inhibitory role on the late differentiation phase. The numerical approach used in this study suggested 6-8 mM as the most effective concentration of Mg2+ ions in promoting the early differentiation process. Also, the proposed model sheds light on the fundamental differences in the behavioral properties of cells cultured in different experiments, e.g. differentiation rate and the sensitivity of the cultured cells to stimulatory signals such as Mg2+ ions. Thus, it can be used to interpret and compare different empirical findings. Moreover, the model successfully reproduced the nonlinearities in the concentration-dependent role of the inflammatory cytokines in early and late differentiation rates. Overall, the proposed model can be employed in studying the osteogenic properties of Mg-based implants in the presence of an inflammatory response.