It travels up the xylem to the leaves. In the leaf, water enters the air spaces as water vapour . As photosynthetic cells use water more is drawn into them, again the process is osmosis . The water passes out through the stomatal pores in this situation. In this case the process is diffusion , as water is passing down its concentration gradient.
Diffusion is also the process by which gases move in and out of the leaf.
In the case of photosynthesis dominating, CO 2 is used by the cells. The concentration gradient of CO 2 is therefore high in the air spaces, lower in the cell, so the CO 2 diffuses into the cell. This means that the leaf air spaces become deficient in CO 2 when compared with the external environment. Thus CO 2 diffuses into the leaf via the stomatal pores. Using similar reasoning, it can be expalined why O 2 diffuses out of the leaves of photosynthesising plants.