Oxygen is a byproduct of photosynthesis.
Green plants use chlorophyll in their leaves to absorb light, they use this light to react carbon dioxide with water to produce glucose. This glucose is used in respiration or converted to starch and stored. Oxygen is produced as a byproduct.