Nitrogen-doped carbon nanomaterials have greater capacity and better cycling stability for Li-ion batteries as compared to undoped carbon materials. In situ near-edge X-ray absorption fine structure (NEXAFS) spectroscopy in combination with quantum chemical modeling has been applied to determine the chemical states of the incorporated nitrogen after interaction with lithium. NEXAFS N K-edge spectra of nitrogen-doped porous carbon were measured before and after thermal deposition of Li vapors. The simulation and interpretation of NEXAFS data were carried out based on density functional theory calculations of initial and lithiated graphene fragments that contained different nitrogen species. The preferable interactions of Li with pyridinic and hydrogenated pyridinic nitrogen which are located at edges of atomic vacancies and graphene planes were revealed.