Oxygen is primarily replaced through the process of photosynthesis, where plants use the energy from the sun to convert carbon dioxide and water into oxygen and glucose. This process occurs in the chloroplasts of plant cells, where chlorophyll pigments capture light energy. The light energy is used to split water molecules, releasing oxygen as a byproduct. The oxygen produced by plants is then released into the atmosphere through their stomata, small pores on the leaves.