Porous coordination polymers are materials formed from metal ions that are bridged together by organic linkers and that can combine two seemingly contradictory properties-crystallinity and flexibility. Porous coordination polymers can therefore create highly regular yet dynamic nanoporous domains that are particularly promising for sorption applications. Here, we describe the effective selective sorption of dioxygen and nitric oxide by a structurally and electronically dynamic porous coordination polymer built from zinc centres and tetracyanoquinodimethane (TCNQ) as a linker. In contrast to a variety of other gas molecules (C2 H2, Ar, CO2, N2 and CO), O2 and NO are accommodated in its pores. This unprecedented preference arises from the concerted effect of the charge-transfer interaction between TCNQ and these guests, and the switchable gate opening and closing of the pores of the framework. This system provides further insight into the efficient recognition of small gas molecules.