Near-edge X-ray absorption fine structure (NEXAFS) spectroscopy is a powerful technique for characterizing the composition and bonding state of nanoscale materials and the top few nanometers of bulk and thin film specimens. When coupled with imaging methods like photoemission electron microscopy, it enables chemical imaging of materials with nanometerscale lateral spatial resolution. However, analysis of NEXAFS spectra is often performed under the assumption of structural and compositional homogeneity within the nanometer-scale depth probed by this technique. This assumption can introduce large errors when analyzing the vast majority of solid surfaces due to the presence of complex surface and near-surface structures such as oxides and contamination layers. An analytical methodology is presented for removing the contribution of these nanoscale overlayers from NEXAFS spectra of two-layered systems to provide a corrected photo-absorption spectrum of the substrate. This method relies on the subtraction of the NEXAFS spectrum of the overlayer adsorbed on a reference surface from the spectrum of the two-layer system under investigation, where the thickness of the overlayer is independently determined by X-ray photoelectron spectroscopy (XPS). This approach is applied to NEXAFS data acquired for one of the most challenging cases: air-exposed hard carbon-based materials with adventitious carbon contamination from ambient exposure. The contribution of the adventitious carbon was removed from the as-acquired spectra of ultrananocrystalline diamond (UNCD) and hydrogenated amorphous carbon (a-C:H) to determine the intrinsic photoabsorption NEXAFS spectra of these materials. The method alters the calculated fraction of sp 2 -hybridized carbon from 5 to 20%, and reveals that the adventitious contamination can be