The structure of the leaf is adapted for gas exchange. The cells in the spongy mesophyll (lower layer) are loosely packed, and covered by a thin film of water. There are tiny pores, called stomata, in the surface of the leaf. Most of these are in the lower epidermis, away from the brightest sunlight.
The stomata control gas exchange in the leaf. Each stoma can be open or closed, depending on how turgid its guard cells are.
In the light, the guard cells absorb water by osmosis, become turgid and the stoma opens.
In the dark, the guard cells lose water, become flaccid and the stoma closes.
Diffusion of carbon dioxide, oxygen and water vapour into (or out of) the leaf is greatest when the stomata are open.