The synthesis of ATP through the movement of protons down their electrochemical gradient across a partially permeable membrane, catalysed by ATP synthase. As the protons move down, energy is released for the attachment of an inorganic phosphate to ADP forming ATP.