The bacterial flagellar motor is a reversible rotary nano-machine, about 45 nm in diameter, embedded in the bacterial cell envelope. It is powered by the flux of H+ or Na+ ions across the cytoplasmic membrane driven by an electrochemical gradient, the proton-motive force or the sodium-motive force. Each motor rotates a helical filament at several hundreds of revolutions per second (hertz). In many species, the motor switches direction stochastically, with the switching rates controlled by a network of sensory and signalling proteins. The bacterial flagellar motor was confirmed as a rotary motor in the early 1970s, the first direct observation of the function of a single molecular motor. However, because of the large size and complexity of the motor, much remains to be discovered, in particular, the structural details of the torque-generating mechanism. This review outlines what has been learned about the structure and function of the motor using a combination of genetics, single-molecule and biophysical techniques, with a focus on recent results and single-molecule techniques.