The two gases that move in and out of the stomata on plant leaves are carbon dioxide and oxygen. The exchange of these two gases plays a vital role in photosynthesis, which is the process by which plants use light to produce and store the energy they require for their metabolic needs. In addition to light, carbon dioxide and water are required for this process to occur, and oxygen is a byproduct.
The stomata are the microscopic pores located on the epidermal portions of land plants that enable the carbon dioxide and oxygen gas exchange to take place. Guard cells surrounding each stoma open and close the stomatal pores in response to both environmental changes and conditions within the plant. When the guard cells absorb water, they become turgid and elongate. This causes the stomatal pores they surround to open. When guard cells lose water, they shrink and cause the pores they surround to close. Although the full extent of how the guard cell's response mechanisms work is not completely understood, it is known that the change of osmotic pressure within these cells determines whether the stomatal pore is opened or closed.
The degree of light, water and atmospheric carbon dioxide in a land plant's environment are critical factors in its survival. These factors also determine how long the stomata will remain open to take in carbon dioxide and how much water vapor will be kept inside by the plant closing its stomatal pores.