Mg-doped GaN(0001) epitaxial layers, grown by molecular beam epitaxy in a setup interconnected with an analytic chamber, were analysed by means of X-ray photoelectron spectroscopy to study their physicochemical properties under different preparation methods. Investigations were carried out for the following samples: asgrown, air-exposed and treated with isopropanol (IPA) or HCl, and in situ cleaned. The X-ray photoelectron spectroscopy results confirmed that the air-exposed samples are contaminated with oxygen and carbon atoms, which can be removed only by in situ cleaning. The valence band maximum varies in the range from 1.2 eV to 2.7 eV below the Fermi level for the as-grown and ex situ prepared samples, respectively. The valence band maximum for in situ cleaned sample is located at 1.7 eV below the Fermi level.