Water has a capacity to carry a set amount of dissolved gasses; the amount of these dissolved gasses in the water depends upon a number of factors, and has a direct effect upon the fish.
Gas exchange takes place at the waters surface whereby gasses are either released into, or absorbed from the atmosphere.
Although other gasses are involved, the most important in the aquarium are oxygen and carbon dioxide. Oxygen is used up in the aquarium during respiration by fish, and even more so, by bacteria. The oxygen that is used up will be replaced by gas exchange at the waters surface from the surrounding air.
The amount of oxygen that is transferred is dependant upon the surface area of the water; a larger surface area results in more places where gas exchange can take place. Circulation of water at the surface, and throughout the aquarium will increase gas exchange by taking oxygen-rich water away from the surface, and replacing it with lower-oxygen water.
The gas exchange in an aquarium can be increased by agitating the surface with air pumps, or water pumps (including the filter), which both increase the surface area and increase water circulation.
Gas exchange also works to remove gasses from the water if they become in excess, this is often the case with carbon dioxide. Although carbon dioxide is useful for plants, for other organisms it is a waste product created through respiration and too high a level can become dangerous and cause respiratory problems.
Excesses of carbon dioxide are released from the water via gas exchange at the waters surface, which again is increased by surface agitation and water circulation.
Gas exchange is not limited to the aquariums water and the atmosphere and takes place in a number of different areas, such as in the gills of fishes.