The homo- and hetero-tetrameric channel complexes formed by transient receptor potential cation channel, subfamily M, member 6 (TRPM6) and 7 (TRPM7) (collectively referred to as TRPM6/TRPM7 channels in this study) are the major regulators of cellular magnesium uptake, yet the exact roles of TRPM6/TRPM7 channels and cellular magnesium homeostasis during development are poorly understood. Here, we report a novel small molecule Mesendogen (MEG) which robustly induces nearly homogeneous (≥85%) mesoderm and definitive endoderm (DE) differentiations of human embryonic stem cells (hESCs) in combination with growth factors. A kinome screen followed by loss-of-function experiments identified TRPM6 as the biological target of MEG. We demonstrated that MEG functions by inhibiting TRPM6/TRPM7 magnesium channel activity, as MEG reduced intracellular magnesium level, while TRPM6/TRPM7 channel modulation and magnesium-withdrawal phenocopied MEG at enhancing mesoderm and DE differentiations. This study discovers a robust chemical enhancer of hESC directed differentiation, and uncovers a novel regulatory role of cellular magnesium homeostasis during early embryonic cell fate specification.