During photosynthesis in plants, ATP is synthesized by ATP synthase using a proton gradient created in the thylakoid lumen through the thylakoid membrane and into the chloroplast stroma. ATP synthase consists of two main subunits, FO and F1, which has a rotational motor mechanism allowing for ATP production.