Dehydration of fructose to 5-hydroxymethylfurfural (HMF) is a critical step in the cost-effective cascade conversion of biomass-feedstocks to advanced biofuels, fuel additives, biopolymers, and biochemicals. In this work, the surface chemistry of phosphorus-doped carbon xerogels (CX_P) was studied to identify the ways to boost their catalytic performance in the eco-friendly production of HMF. An excellent HMF yield of 73.3% from dehydration of fructose was obtained in just 2 h in the H2O-CO2 reaction system, using CX_P thermally treated in air. This was achieved by controlling the amount and type of active sites on the catalyst surface and by modifying of the reaction atmosphere. The best-performing catalyst exhibited Brønsted acids in the form of P-OH in proximity to high amounts of thermally stable oxygen functionalities such as phenol, carbonyl, and lactone, which were vital for obtaining a high yield of HMF. A positive correlation was obtained between the selectivity towards HMF and the total amount of oxygen present in the bulk of the catalysts. The oxygen groups improved selectivity towards HMF by hindering its further adsorption and degradation. In addition, the selectivity to HMF was dependnt on the ratio between O-functionalities and PO phosphates together with COP species. We finally demonstrated a superior green catalytic system to promote fructose dehydration to HMF under green conditions using pure water under a CO2 atmosphere.