Biological ion channels have remarkable ion selectivity, permeability and rectification properties, but it is challenging to develop artificial analogues. Here, we report a metal–organic framework-based subnanochannel (MOFSNC) with heterogeneous structure and surface chemistry to achieve these properties. The asymmetrically structured MOFSNC can rapidly conduct K+, Na+ and Li+ in the subnanometre-to-nanometre channel direction, with conductivities up to three orders of magnitude higher than those of Ca2+ and Mg2+, equivalent to a mono/divalent ion selectivity of 103. Moreover, by varying the pH from 3 to 8 the ion selectivity can be tuned further by a factor of 102 to 104. Theoretical simulations indicate that ion–carboxyl interactions substantially reduce the energy barrier for monovalent cations to pass through the MOFSNC, and thus lead to ultrahigh ion selectivity. These findings suggest ways to develop ion selective devices for efficient ion separation, energy reservation and power generation.