Context. Comets are considered to be remnants from the formation of the Solar System. ESA’s Rosetta mission targeted comet 67P/Churyumov-Gerasimenko and was able to record high-quality data on its chemical composition and outgassing behaviour, including low abundances of N2 that are observed to be correlated with H2O and CO2 in approximately a 63:37 ratio. Aims. In this work, the thermal desorption behaviour of N2 in H2O:CO2 ices was studied in the laboratory to investigate the co-desorption behaviour of N2 within the two most abundant cometary ices in 67P and to derive desorbing fractions in different temperature regimes. Methods. H2O:CO2:N2 ices of various ratios were prepared in a gas mixing system and co-deposited at 15 K onto a copper sample holder. Sublimation of the ice was measured using temperature programmed desorption mass spectrometry. Quantitative values were derived for the fraction of N2 co-desorbing with CO2 and H2O respectively. To validate the results, H2O:CO2:13CO ices were prepared as well. Results. The experiments show that the co-desorption of N2 with CO2 in H2O:CO2:N2 ices depends on the bulk amount of CO2 present in the ice. The fraction of N2 trapped in H2O reduces as more N2 and CO2 are added to the mixture. CO behaves qualitatively similar to N2, but more CO is found to co-desorb with CO2. To reproduce the ratio of N2 desorbing with H2O over that of CO2 (N2(H2O)/N2(CO2)), our ice analogues need to contain ≥15% CO2, while 67P contains ≤7.5% CO2. Large fractions of N2 can be removed from the ice due to heating up to 70 K, but for ice that most closely resembles that of 67P, the loss fraction of pure phase N2 is expected to be ≤20%. Therefore, N2 is suggested to be a minor carrier of nitrogen in the comet.