ATP synthase is an enzyme that catalyzes the formation of the energy storage molecule adenosine triphosphate (ATP) using adenosine diphosphate (ADP) and inorganic phosphate (P). ATP synthase is a molecular machine. The overall reaction catalyzed by ATP synthase is:
* ADP + P + 2H  ATP + HO + 2H
ATP synthase lies across a cellular membrane and forms an aperture that protons can cross from areas of high concentration to areas of low concentration, imparting energy for the synthesis of ATP. This electrochemical gradient is generated by the electron transport chain and allows cells to store energy in ATP for later use. In  prokaryotic cells ATP synthase lies across the plasma membrane, while in  eukaryotic cells it lies across the inner mitochondrial membrane. Organisms capable of photosynthesis also have ATP synthase across the thylakoid membrane, which in plants is located in the chloroplast and in cyanobacteria is located in the cytoplasm.
Eukaryotic ATP synthases are F-ATPases, running "in reverse" for an ATPase. This article deals mainly with this type. An F-ATPase consists of two main subunits, F and F, which has a rotational motor mechanism allowing for ATP production.