X-ray diffraction and optical spectroscopy techniques are used to characterize stable and metastable transformations of nitrogen compressed up to 170 GPa and heated above 2500 K. X-ray diffraction data show that varepsilon-N2 undergoes two successive structural changes to complex molecular phases zeta at 62 GPa and a newly discovered kappa at 110 GPa. The latter becomes an amorphous narrow gap semiconductor on further compression and if subjected to very high temperatures (approximately 2000 K) crystallizes to the crystalline cubic-gauche-N structure (cg-N) above 150 GPa. The diffraction data show that the transition to cg-N is accompanied by 15% volume reduction.