Context. Molecular nitrogen is one of the key species in the chemistry of interstellar clouds and protoplanetary disks, but its photodissociation under interstellar conditions has never been properly studied. The partitioning of nitrogen between N and N 2 controls the formation of more complex prebiotic nitrogen-containing species. Aims. The aim of this work is to gain a better understanding of the interstellar N 2 photodissociation processes based on recent detailed theoretical and experimental work and to provide accurate rates for use in chemical models. Methods. We used an approach similar to that adopted for CO in which we simulated the full high-resolution line-by-line absorption + dissociation spectrum of N 2 over the relevant 912-1000 Å wavelength range, by using a quantum-mechanical model which solves the coupled-channels Schrödinger equation. The simulated N 2 spectra were compared with the absorption spectra of H 2 , H, CO, and dust to compute photodissociation rates in various radiation fields and shielding functions. The effects of the new rates in interstellar cloud models were illustrated for diffuse and translucent clouds, a dense photon dominated region and a protoplanetary disk. Results. The unattenuated photodissociation rate in the Draine (1978, ApJS, 36, 595) radiation field assuming an N 2 excitation temperature of 50 K is 1.65 × 10 −10 s −1 , with an uncertainty of only 10%. Most of the photodissociation occurs through bands in the 957-980 Å range. The N 2 rate depends slightly on the temperature through the variation of predissociation probabilities with rotational quantum number for some bands. Shielding functions are provided for a range of H 2 and H column densities, with H 2 being much more effective than H in reducing the N 2 rate inside a cloud. Shielding by CO is not effective. The new rates are 28% lower than the previously recommended values. Nevertheless, diffuse cloud models still fail to reproduce the possible detection of interstellar N 2 except for unusually high densities and/or low incident UV radiation fields. The transition of N → N 2 occurs at nearly the same depth into a cloud as that of C + → C → CO. The orders-of-magnitude lower N 2 photodissociation rates in clouds exposed to black-body radiation fields of only 4000 K can qualitatively explain the lack of active nitrogen chemistry observed in the inner disks around cool stars. Conclusions. Accurate photodissociation rates for N 2 as a function of depth into a cloud are now available that can be applied to a wide variety of astrophysical environments.