The phase diagram of the Mg−C system has been constructed up to 20 GPa and ∼4000 K based on complementary Thermo-Calc simulations and experimental data obtained in both ex situ and in situ experiments using X-ray diffraction with synchrotron radiation. Three high-pressure magnesium carbides, namely, β-Mg 2 C 3 , its high-temperature form γ-Mg 2 C 3 , and antifluorite Mg 2 C, have p−T domains of thermodynamic stability. At the same time, the carbides accessible by ambient-pressure synthesis, α-Mg 2 C 3 and MgC 2 , are either metastable or unstable, depending on the temperature, at least up to 20 GPa. Experimental observations show that at ambient conditions, all carbides are metastable and remain unchanged at least for years. 9