Rust is a fact of life on Earth as well as at least one other planet in the solar system: Mars. The reddish tinge of that planet is largely due to the presence of iron oxide, or rust, on its surface. Rust is the result of the combination of iron with oxygen in a process called oxidation, and the presence of rust on Mars suggests there may have been more molecular oxygen on the planet in the past, although carbon dioxide, which is the main component of Mars' present atmosphere, can also supply oxygen. Besides gaseous oxygen, the formation of rust needs water because it's a two-step process. That's an indication that water may have been abundant on Mars long ago.
TL;DR (Too Long; Didn't Read)
The formation of rust requires iron, water and oxygen. Although it's a complex process, the chemical equation is simply 4Fe + 3O2 + 6H2O → 4Fe(OH)3.
The First Step: Oxidation of Solid Iron
It's common knowledge that rust occurs when you leave water on a metal implement or you leave it exposed to moist air. That's because the first step in the rusting process involves the dissolution of solid iron into solution. The formula for this is:
Fe(s) → Fe2+(aq) + 2e-
The electrons produced by this reaction combine with hydrogen ions in the water as well as with dissolved oxygen to produce water:
4e- + 4H+(aq) + O2(aq) → 2H2O(l)
These two reactions produce water and iron(II) ions, but not rust. For that to form, another reaction has to occur.
The Second Step: Formation of Hydrated Iron Oxide (Rust)
The consumption of hydrogen ions that occurs as iron dissolves leaves a preponderance of hydroxide (OH-) ions in the water. The iron(II) ions react with them to form green rust:
Fe2+(aq) + 2OH-(aq) → Fe(OH)2(s)
That isn't the end of the story. The iron(II) ions also combine with hydrogen and oxygen in the water to produce iron(III) ions:
4Fe2+(aq) + 4H+(aq) + O2(aq) → 4Fe3+(aq) + 2H2O(l)
These iron ions are responsible for the formation of the reddish deposit that gradually eats holes in auto bodies and metal roofing worldwide. They combine with the extra hydroxide ions to form iron(III) hydroxide:
Fe3+(aq) + 3OH-(aq) → Fe(OH)3
This compound dehydrates to become Fe2O3.H2O, which is the chemical formula for rust.
Writing the Balanced Equation
If you're interested in writing a balanced equation for the entire process, you need only know the initial reactants and the products of the reaction. The reactants are iron (Fe), oxygen (O2) and water (H2O), and the product is iron (III) hydroxide Fe(OH)3, so Fe + O2 + H2O → Fe(OH)3. In a balanced equation, the same number of oxygen, hydrogen and iron atoms must appear on both sides of the equation. Balance the number of hydrogen atoms by multiplying the number of water molecules by 6 and the number of hydroxide molecules by 4. You then have to multiply the number of O2 molecules by 3 and the number of Fe ions by 4. The result is:
4Fe + 3O2 + 6H2O → 4Fe(OH)3