Rusting of iron consists of the formation of hydrated oxide, Fe(OH)3, FeO(OH), or even Fe2O3.H2O. It is an electrochemical process which requires the presence of water, oxygen and an electrolyte. In the absence of any one of these rusting does not occur to any significant extent. In air, a relative humidity of over 50% provides the necessary amount of water and at 80% or above corrosion of bare steel is worse.
When a droplet of water containing a little dissolved oxygen falls on an steel pipe, the solid iron or Fe(s) under the droplet oxidizes:
Fe(s) --> Fe2+(aq) + 2e-
The electrons are quickly consumed by hydrogen ions from water (H2O) and dissolved oxygen or O2(aq) at the edge of the droplet to produce water:
4e- + 4H+(aq) + O2(aq) --> 2H2O(l)
More acidic water increases corrosion. If the pH is very low the hydrogen ions will consume the electrons anyway, making hydrogen gas instead of water:
2H+(aq) + 2e- --> H2(g)
But where's the rust? The equations above tell only a small part of the story.
Hydrogen ions are being consumed by the process. As the iron corrodes, the pH in the droplet rises. Hydroxide ions (OH-) appear in water as the hydrogen ion concentration falls. They react with the iron(II) ions to produce insoluble iron(II) hydroxides or green rust:
Fe2+(aq) + 2OH-(aq) --> Fe(OH)2(s)
The iron(II) ions also react with hydrogen ions and oxygen to produce iron(III) ions:
4Fe2+(aq) + 4H+(aq) + O2(aq) -->4Fe3+(aq) + 2H2O(l)
The iron(III) ions react with hydroxide ions to produce hydrated iron(III) oxides (also known as iron(III) hydroxides):
Fe3+(aq) + 3OH-(aq) --> Fe(OH)3(s)
The loose porous rust or Fe(OH)3 can slowly transform into a crystallized form written as Fe2O3.H2O the familiar red-brown stuff that is called "rust" forming tubercles as shown here. Since these processes involve hydrogen ions or hydroxide ions, they will be affected by changes in pH. With limited O2, magnetite is formed (Fe3O4).
If other ions like calcium or carbonate are present, they make a variety of precipitates that mix in with the iron hydroxide to produce a crusty, twisted coating which can either slow corrosionby cutting the iron off from the acid, water, and air supply or grow into convoluted shapes called tubercles. The growth of these tubercles can greatly affect the flow of water through water mains as shown here.