Efficient and sustainable methods for carbon dioxide capture are highly sought after. Mature technologies involve chemical reactions that absorb CO2, but they have many drawbacks. Energy-efficient alternatives may be realised by porous physisorbents with void spaces that are complementary in size and electrostatic potential to molecular CO2. Here, we present a robust, recyclable and inexpensive adsorbent termed MUF-16. This metal-organic framework captures CO2 with a high affinity in its one-dimensional channels, as determined by adsorption isotherms, X-ray crystallography and density-functional theory calculations. Its low affinity for other competing gases delivers high selectivity for the adsorption of CO2 over methane, acetylene, ethylene, ethane, propylene and propane. For equimolar mixtures of CO2/CH4 and CO2/C2H2, the selectivity is 6690 and 510, respectively. Breakthrough gas separations under dynamic conditions benefit from short time lags in the elution of the weakly-adsorbed component to deliver high-purity hydrocarbon products, including pure methane and acetylene.