The abundance of interstellar molecular nitrogen (N2) is of considerable importance: models of steady-state gas-phase interstellar chemistry, together with millimetre-wavelength observations of interstellar N2H+ in dense molecular clouds predict that N2 should be the most abundant nitrogen-bearing molecule in the interstellar medium. Previous attempts to detect N2 absorption in the far-ultraviolet or infrared (ice features) have hitherto been unsuccessful. Here we report the detection of interstellar N2 at far-ultraviolet wavelengths towards the moderately reddened star HD 124314 in the constellation of Centaurus. The N2 column density is larger than expected from models of diffuse clouds and significantly smaller than expected for dense molecular clouds. Moreover, the N2 abundance does not explain the observed variations in the abundance of atomic nitrogen (NI) towards high-column-density sightlines, implying that the models of nitrogen chemistry in the interstellar medium are incomplete.