Rare earth elements (REEs), including scandium, yttrium and lanthanides, are strategic resources with unique electric, luminescent and magnetic properties. However, owing to their highly similar physiochemical properties, the identification and separation of all REEs are challenging. Here a Mycobacterium smegmatis porin A nanopore is engineered to contain a nitrilotriacetic acid ligand at its pore constriction. By the further introduction of a secondary ligand N