Molecular nitrogen (N2) is thought to have been the most abundant form of nitrogen in the protosolar nebula. It is the main N-bearing molecule in the atmospheres of Pluto and Triton and probably the main nitrogen reservoir from which the giant planets formed. Yet in comets, often considered the most primitive bodies in the solar system, N2 has not been detected. Here we report the direct in situ measurement of N2 in the Jupiter family comet 67P/Churyumov-Gerasimenko, made by the Rosetta Orbiter Spectrometer for Ion and Neutral Analysis mass spectrometer aboard the Rosetta spacecraft. A N2/CO ratio of (5.70 ± 0.66) × 10-3 (2σ standard deviation of the sampled mean) corresponds to depletion by a factor of ˜25.4 ± 8.9 as compared to the protosolar value. This depletion suggests that cometary grains formed at low-temperature conditions below ˜30 kelvin.