Diffusion is the spreading of particles from where there are many of them (high concentration) to where there are fewer (low concentration).
When leaf cells photosynthesise, they use up carbon dioxide. So there is less carbon dioxide inside the leaf than in the air outside, and carbon dioxide diffuses in through the stomata.
The cells also make oxygen, so there is more oxygen inside than outside. Oxygen diffuses out through the stomata into the air. (A little of it is used by the leaf's own cells for respiration.)
Try it: push a fresh leaf under warm water. Bubbles come out, mostly from the lower surface. The bubbles are air from inside the leaf: warming makes the gas expand, so it escapes through the stomata. Most bubbles come from the underside because that is where most stomata are.
Tap the diagram to enlarge it
- CO₂ in
- O₂ out
- High → low concentration