To elucidate the effect of nitrogen functional groups on toluene adsorption under humid conditions, a series of N-doped resorcinol-formaldehyde resin-based activated carbons (HNRCs) using g-C3N4 as the nitrogen source were prepared, which possessed different N contents (1.29–6.14%) and similar O contents, named HRC, HNRC1, HNRC3 and HNRC5, respectively. In this study, breakthrough experiments of toluene were conducted and the results showed that under RH50%, the saturated adsorption capacity towards toluene agreed with the BET surface area and micropore volume. Nevertheless, the normalized adsorption capacity of samples was consistent with N content. Moreover, the adsorption isotherms of toluene and water vapor were analyzed, displaying that nitrogen functional groups can not only contribute to the adsorption of toluene but also improve the hydrophobicity of carbon surface, especially graphitic N. Temperature programmed desorption experiments and density functional theory (DFT) calculations further demonstrated that the introduction of N can help to enhance the competitive adsorption of toluene from water vapor. This is because the N functional groups can enhance the π-π interaction between toluene and the carbon surface by facilitating the polarization of π electrons. Meanwhile, N functional groups can weaken the van der Waals interaction between the carbon surface and water vapor. This study would provide the theoretical hints to develop the VOCs adsorbents in the presence of water vapor.