The reactants in photosynthesis are carbon dioxide (CO2) and water (H2O). Both contain oxygen, but from which compound does the O2 that we breathe come from? The assumption some time ago was that the oxygen in carbon dioxide eventually formed atmospheric oxygen. However, an experiment in the 1950s using a radioactive tracer (18O) followed the path of O2 back to H2O and not CO2. 

The special chlorophyll a molecules of Photosystem II holds a water molecule so that a few photons of light will strike the electron bonds holding the hydrogen atoms to the Oxygen atom. When that happens, the water molecule releases its hydrogen atoms and they go to the next step where they are combined with Carbon dioxide for further processing. The Oxygen is released and combines with another Oxygen molecule.
O2 is released from H2O(water)