Recently, the first known light-driven sodium pumps, from the microbial rhodopsin family, were discovered. We have solved the structure of one of them, Krokinobacter eikastus rhodopsin 2 (KR2), in the monomeric blue state and in two pentameric red states, at resolutions of 1.45 Å and 2.2 and 2.8 Å, respectively. The structures reveal the ion-translocation pathway and show that the sodium ion is bound outside the protein at the oligomerization interface, that the ion-release cavity is capped by a unique N-terminal α-helix and that the ion-uptake cavity is unexpectedly large and open to the surface. Obstruction of the cavity with the mutation G263F imparts KR2 with the ability to pump potassium. These results pave the way for the understanding and rational design of cation pumps with new specific properties valuable for optogenetics.