I understand what the enzyme ATP synthase does, but I'm not exactly sure how it does it. I've heard that it uses rotary catalysis, but how exactly does this work? How is the energy from the H+ ion harnessed, turned into mechanical energy, and then finally into the chemical energy stored in ATP? Why does the spinning of parts of the enzyme need to occur for this to happen?
Image from wikipedia page on ATP synthase
In brief, the addition and release of protons to the structure cause a conformational change that leads to another conformational change. This series of conformational changes occurs in such a way that it induces a rotational motion.
The rotation of the central axel that extends through both hemispheres of this large complex is driven by the proton gradient. Specific residues in the c12 ring are protonated in order to drive this rotation. A high concentration of protons (in this picture the high concentration is found above the complex) allows each of the subunits in the membrane to be constantly loaded with H+ ammunition, ready to fire when it comes to be their turn.
The function of this axel is to slightly but significantly change the shape of one subunit at at a time in the red part.
Changing the conformation of subunits in the red part is what allows for the three steps in ATP synthesis to occur: binding of ADP and Pi, catalysis of the formation of ATP, and release of ATP.
All of these changes occur at the molecular level. The proton forms a bond with a single amino acid of the entire protein complex, but this is sufficient to cause a difference in the most stable 3-dimensional structure of the whole. This could cause either a cascade of changes that result in a net rotation or it could cause a re-stabilization of the structure due to electrostatic forces.
According to Vinit K. Rastogi & Mark E. Girvin in their 1999 Nature paper on the subject, it's more like the former:
The whole paper's a good read. But this is as current as I am on the topic, and it's likely that a more detailed mechanism has been determined for the action of ATP synthase since 1999.