Stable structures and stoichiometries of binary Mg−N compounds are explored at pressures from ambient up to 300 GPa using ab initio evolutionary simulations. In addition to Mg 3 N 2 , we identified five nitrogen-rich compositions (MgN 4 , MgN 3 , MgN 2 , Mg 2 N 3 , and Mg 5 N 7 ) and three magnesium-rich ones (Mg 5 N 3 , Mg 4 N 3 and Mg 5 N 4 ), which have stability fields on the phase diagram. These compounds have peculiar structural features, such as N 2 dumbbells, bent N 3 units, planar SO 3 -like N(N) 3 units, N 6 six-membered rings, 1D polythiazyl S 2 N 2 -like nitrogen chains, and 2D polymeric nitrogen nets. The dimensionality of the nitrogen network decreases as magnesium content increases; magnesium atoms act as a scissor by transferring valence electrons to the antibonding states of nitrogen sublattice. In this context, pressure acts as a bonding glue in the nitrogen sublattice, enabling the emergence of polynitrogen molecule-like species and nets. In general, Zintl−Klemm concept and molecular orbital analysis proved useful for rationalizing the structural, bonding and electronic properties encountered in the covalent nitrogen-based units. Interestingly, covalent six-membered N 6 4− rings containing P−1 (I) MgN 3 phase is recoverable at atmospheric pressure. Moreover, ab initio molecular dynamics analysis reveals the polymeric covalent nitrogen network, poly-N 4 2− , encountered in the high-pressure Cmmm MgN 4 phase can be preserved at ambient conditions. Thus, quenchable MgN 4 , stable at pressures above 13 GPa, shows that high energy-density materials based on polymeric nitrogen can be achievable at reduced pressures. The highpressure phase P−1 (I) MgN 3 with covalent N 6 rings is the most promising HEDM candidate with an energy density of 2.87 kJ• g −1 , followed by P−1 MgN 4 (2.08 kJ•g −1 ).