In the final stage of aerobic respiration, the energy for the phosphorylation of ATP to ADP comes from the activity of the electron transport chain. This takes place in the mitochondrial membranes.
Reduced NAD and reduced FAD are passed to the electron transport chain. Here hydrogens are removed from the hydrogen carriers and each is split into its constituent hydrogen ion (H+). Once the electron is transferred to oxygen a hydrogen ion will be drawn from solution to reduce the oxygen to water. The transfer of electrons along the series of electron carriers makes energy available which is used to convert ADP to ATP.
The hydrogen ions are pumped into the intermembrane space of the mitochondria. As they diffuse back they pass through stalk proteins on the inner membrane. These contain the protein ATP synthase. As hydrogen ions pass through, its three binding sites rotate between the states of attaching ADP and Pi, binding ADP and Pi and releasing ATP.