Rust is the product of a chemical reaction in which iron oxidizes in the presence of an electrolyte. In order to form iron oxide, exposed iron must bond with oxygen, which usually happens when the iron surface gets wet.
Oxidation is a chemical reaction in which electrons pass from a donor atom, called an anode, to a recipient atom, called a cathode, through an electrolyte. Iron is highly conductive, so it is capable of acting as both cathode and anode in an oxidation reaction. When water falls as rain, it takes up carbon from the atmosphere and becomes a weak form of carbonic acid. This acid begins dissolving iron as soon as it comes into contact with a ferrous surface. This creates a thin electrolyte soup that facilitates the passage of electrons from some iron atoms, the anodes, to the cathodes. During this transfer, iron atoms are eager to bond with oxygen, which forms large molecules of iron oxide, or rust. Iron oxide molecules are much larger than iron molecules alone, so the resulting patina of rust cannot adhere to the underlying layer of iron and rapidly flakes off. This exposes fresh iron to be oxidized in turn until the entire surface has been corroded.