Oxygen plays a crucial role in corrosion by facilitating the reaction between the metal and its environment. In the presence of oxygen, the metal reacts with water to form an oxide layer, which can be protective or non-protective depending on the metal and environmental conditions. In aerobic environments, oxygen can accelerate corrosion by increasing the rate of oxidation reactions. However, in anaerobic environments, corrosion can still occur through anaerobic reactions, such as those involving sulfur-reducing bacteria.