One of the goals of photosynthesis is to make ATP. ATP is frequently employed in biology to drive uphill reactions. The hydrolysis of ATP to give ADP is a downhill reaction, so it releases energy.
Formation of ATP from ADP requires addition of phosphate. It's an uphill reaction, so the cell has to expend energy to produce ATP. ATP synthase harnesses a proton gradient to drive a molecular rotor, much like a millwheel, in order to bring ADP and phosphate in close proximity so that they can form ATP. You may already be familiar with ATP synthase from oxidative phosphorylation, where it works exactly the same way.
ATP synthase is thought of as having three states. In the "loose" state, ADP and phosphate (Pi) can enter the binding site easily. Once these two substrates are in the binding site, the enzyme enters the "tight" state, in which ADP and phosphate are constricted and form ATP. At that point, the enzyme goes through an "open" phase in which ATP can leave easily.
As in oxidative phosphorylation, the changes in states are coupled to rotation of one part of the multiprotein complex (the rotor) with respect to another (the stator). The principle is similar to that of an electric motor. If the stator is positively charged and certain positions of the rotor are negatively charged, then the opposite charges will attract and the rotor will begin to turn. Once the negatively charged part of the rotor reaches the positively charged part of the stator, however, everything should come to a stop. The reason it doesn't is because a proton drops into the the anionic position of the rotor just as it is approaching the stator. Now neutralized, this position is no longer attracted to the stator, and it just sails past. Meanwhile, another anionic position is approaching the stator, keeping the rotor turning. As soon as it is a safe distance away from the stator, a hole opens up below the rotor and the protons falls away, regenerating an anionic position that is once again attracted to the next stator.
In the case of photosynthesis, the proton is "dropping in" from the lumen and later "falling down" into the stroma; its motion in that direction is driven by the proton gradient. So that proton gradient in turn drives the motion of the rotor. The motion of the rotor, in turn, drives conformational changes within (and between) the protein subunits of ATP synthase. Those conformational changes promote ATP formation through an approximation effect.