The process used to upgrade natural gas, biogas and refinery-off-gas directly influences the cost of producing the fuel and often requires complex separation strategies and operational systems to remove contaminants such as hydrogen sulfide (H2S) and carbon dioxide (CO2). Here we report a fluorinated metal–organic framework (MOF), AlFFIVE-1-Ni, that allows simultaneous and equally selective removal of CO2 and H2S from CH4-rich streams in a single adsorption step. The simultaneous removal is possible for a wide range of H2S and CO2compositions and concentrations of the gas feed. Pure component and mixed gas adsorption, single-crystal X-ray diffraction and molecular simulation studies were carried out to elucidate the mechanism governing the simultaneous adsorption of H2S and CO2. The results suggest that concurrent removal of CO2 and H2S is achieved via the integrated favourable sites for H2S and CO2 adsorption in a confined pore system. This approach offers the prospect of simplifying the complex schemes for removal of acid gases.