Many essential cellular processes are carried out by complex biological machines located in the cell membrane. The bacterial flagellar motor is a large membrane-spanning protein complex that functions as an ion-driven rotary motor to propel cells through liquid media. Within the motor, MotB is a component of the stator that couples ion flow to torque generation and anchors the stator to the cell wall. Here we have investigated the protein stoichiometry, dynamics and turnover of MotB with single-molecule precision in functioning bacterial flagellar motors in Escherichia coli. We monitored motor function by rotation of a tethered cell body, and simultaneously measured the number and dynamics of MotB molecules labelled with green fluorescent protein (GFP-MotB) in the motor by total internal reflection fluorescence microscopy. Counting fluorophores by the stepwise photobleaching of single GFP molecules showed that each motor contains approximately 22 copies of GFP-MotB, consistent with approximately 11 stators each containing two MotB molecules. We also observed a membrane pool of approximately 200 GFP-MotB molecules diffusing at approximately 0.008 microm2 s(-1). Fluorescence recovery after photobleaching and fluorescence loss in photobleaching showed turnover of GFP-MotB between the membrane pool and motor with a rate constant of the order of 0.04 s(-1): the dwell time of a given stator in the motor is only approximately 0.5 min. This is the first direct measurement of the number and rapid turnover of protein subunits within a functioning molecular machine.