A detailed study of the near-surface structure and composition of Nb, the material of choice for superconducting radio-frequency accelerator (SRF) cavities, is of great importance in order to understand the effects of different treatments applied during cavity production. By means of surface-sensitive techniques such as grazing incidence diffuse x-ray scattering, x-ray reflectivity, and x-ray photoelectron spectroscopy, single-crystalline Nb(100) samples were investigated in and ex situ during annealing in an ultrahigh vacuum as well as in nitrogen atmospheres with temperatures and pressures similar to the ones employed in real Nb cavity treatments. Annealing of Nb specimens up to 800°C in a vacuum promotes a partial reduction of the natural surface oxides (Nb 2 O 5 , NbO 2 , and NbO) into NbO. Upon cooling to 120°C, no evidence of nitrogen-rich layers was detected after nitrogen exposure times of up to 48 h. An oxygen enrichment below the Nb-oxide interface and posterior diffusion of oxygen species towards the Nb matrix, along with a partial reduction of the natural surface oxides, was observed upon a stepwise annealing up to 250°C. Nitrogen introduction to the system at 250°C promotes neither N diffusion into the Nb matrix nor the formation of new surface layers. Upon further heating to 500°C in a nitrogen atmosphere, the growth of a new subsurface Nb x N y layer was detected. These results shed light on the composition of the near-surface region of Nb after low-temperature nitrogen treatments, which are reported to lead to a performance enhancement of SRF cavities.