Understanding the mechanism by which porous solids trap harmful gases such as CO2 and SO2 is essential for the design of new materials for their selective removal. Materials functionalized with amine groups dominate this field, largely because of their potential to form carbamates through H2N(δ−)···C(δ+)O2 interactions, thereby trapping CO2 covalently. However, the use of these materials is energy-intensive, with significant environmental impact. Here, we report a non-amine-containing porous solid (NOTT-300) in which hydroxyl groups within pores bind CO2 and SO2 selectively. In situ powder X-ray diffraction and inelastic neutron scattering studies, combined with modelling, reveal that hydroxyl groups bind CO2 and SO2 through the formation of O=C(S)=O(δ−)···H(δ+)–O hydrogen bonds, which are reinforced by weak supramolecular interactions with C–H atoms on the aromatic rings of the framework. This offers the potential for the application of new ‘easy-on/easy-off’ capture systems for CO2 and SO2 that carry fewer economic and environmental penalties.