The function of a thylakoid is to serve as the compartment where the light-gathering reactions of photosynthesis occur, as explained in "Molecular Biology of the Cell." It is located in the stroma of the choloroplast, which is the space found between the inner membrane and the thylakoid membrane.
Thylakoids are made of an interconnected system of flattened, disc-like sacs. They tend to form stacked aggregates, called grana, which contain approximately 10 to 20 thylakoids each. They contain the electron-transport chain, the photosynthetic light-absorbing system and an ATP synthase enzyme. On the outside of the thylakoid membrane is the stroma, which is the large interior space of the chloroplast and contains enzymes that incorporate CO2 into sugars, ribosomes, RNA and DNA. The membrane of the thylakoids contains important protein complexes that carry out the light reactions of photosynthesis. Photosystem I and II complexes that harvest light with chlorophyll and carotenoids are located there. They absorb light energy and use it to energize the electrons in the electron transport chain. A large protein complex known as ATP synthase controls the concentration gradient of the hydrogen ions in the thylakoid space to generate ATP energy, and the hydrogen ions flow back into the stroma.