The effect of background gas environment on the purity of reactively-deposited nitride films has been studied. Especially, the relation between the oxygen background pressure and its incorporation into the TiN film is investigated in this study. We have developed a UHV sputtering system and deposited TiN films under two different base pressure conditions: one was a UHV condition less than 10-6 Pa, and the other was 1×10-4 Pa of oxygen. The oxygen content of the films was examined with X-ray photoelectron spectroscopy. While no trace of oxygen was detected in the TiN film deposited under the UHV condition, 10 at.% of oxygen was observed in that deposited with the O2 introduction. The extent of O2 incorporation into the TiN film is discussed based on the difference in sticking characteristics of oxygen and nitrogen on the titanium surface.