During oxygen is produced along with glucose (not a gas)
Plants use photosynthesis as a way of producing glucose. They take in light energy from the sun and water and carbon dioxide from the air. This is then used to produce oxygen and glucose. This often considered a reversible reaction as the reverse of this reaction (glucose and oxygen to water carbon dioxide and energy) is respiration.
##carbon dioxide + water + energy -> glucose + oxygen##
##6CO_2 + 6H_2O -> C_6H_12O_6 + 6O_2##
Plants play a major part in maintaining the carbon cycle and therefore the greenhouse effect due to photosynthesis as they taken in carbon dioxide (a greenhouse gas) and produce oxygen (helpful for maintaining the ozone layer and essential for life on earth).
## ##
[More Detail]
Where does this oxygen come from?
Oxygen is released during the light reactions of photosynthesis. Water or ##H_2O## is split during the light reactions into gaseous oxygen or ##O_2## as well as ##H^+## protons and electrons.
The electrons reduce the ##P680^+## pigments in photosystem ##II## once they donate their excited electrons to the primary electron acceptor.
The ##H^+## protons are let off into the stroma and will be used later. The ##O_2## molecules are let off as waste.