The triple bond of diatomic nitrogen has among the greatest binding energies of any molecule. At low temperatures and pressures, nitrogen forms a molecular crystal in which these strong bonds co-exist with weak van der Waals interactions between molecules, producing an insulator with a large band gap. As the pressure is raised on molecular crystals, intermolecular interactions increase and the molecules eventually dissociate to form monoatomic metallic solids, as was first predicted for hydrogen. Theory predicts that, in a pressure range between 50 and 94 GPa, diatomic nitrogen can be transformed into a non-molecular framework or polymeric structure with potential use as a high-energy-density material. Here we show that the non-molecular phase of nitrogen is semiconducting up to at least 240 GPa, at which pressure the energy gap has decreased to 0.4 eV. At 300 K, this transition from insulating to semiconducting behaviour starts at a pressure of approximately 140 GPa, but shifts to much higher pressure with decreasing temperature. The transition also exhibits remarkably large hysteresis with an equilibrium transition estimated to be near 100 GPa. Moreover, we have succeeded in recovering the non-molecular phase of nitrogen at ambient pressure (at temperatures below 100 K), which could be of importance for practical use.