Light-driven sodium pumps actively transport small cations across cellular membranes1. These pumps are used by microorganisms to convert light into membrane potential and have become useful optogenetic tools with applications in neuroscience. Although the resting state structures of the prototypical sodium pump Krokinobacter eikastus rhodopsin 2 (KR2) have been solved2,3, it is unclear how structural alterations over time allow sodium to be translocated against a concentration gradient. Here, using the Swiss X-ray Free Electron Laser4, we have collected serial crystallographic data at ten pump–probe delays from femtoseconds to milliseconds. High-resolution structural snapshots throughout the KR2 photocycle show how retinal isomerization is completed on the femtosecond timescale and changes the local structure of the binding pocket in the early nanoseconds. Subsequent rearrangements and deprotonation of the retinal Schiff base open an electrostatic gate in microseconds. Structural and spectroscopic data, in combination with quantum chemical calculations, indicate that a sodium ion binds transiently close to the retinal within one millisecond. In the last structural intermediate, at 20 milliseconds after activation, we identified a potential second sodium-binding site close to the extracellular exit. These results provide direct molecular insight into the dynamics of active cation transport across biological membranes.