Among other radionuclides, 39Ar and 85Kr are potential background sources in the solar neutrino detector BOREXINO. The expected low event rate requires that the nitrogen used in the experiment needs to have lower concentrations than 0.5 microBq/m3 for 39Ar and 0.2 microBq/m3 for 85Kr, corresponding to volume concentrations in N2 of 0.4 x 10(-6)m3/m3 for Ar and 0.2 x 10(-12)m3/m3 for Kr. Applying gas mass spectrometry and special care in the sampling technique we succeeded in finding the required purity. In addition, we studied the possibility to purify nitrogen from Kr by the adsorption method.