Corrosion is an oxidation process of metals in the presence of water. For iron this process is known as rusting, but it is important to note that many other metals also corrode.

The effects of corrosion are often (ok, essentially always) undesirable. Rust is generally formed at the surface of the metal, and doesn't adhere to the surface. When rust flakes off, the underlying metal is exposed to further corrosion (a process called pitting), and eventually the structural integrity of the metal disintegrates.

The costs associated with corrosion damage are enormous. For example, in the US they add up to approximately 4.2 percent of the GNP (well over 400 billion dollars per year). These costs can be attributed to failure or deterioration of equipment, and the associated downtime, replacement and maintenance.

The overall reaction for the corrosion of iron is as follows:

                          H2O
     4 Fe (s) + 3 O2 (aq)  ->  2 Fe2O3 (s)

The preceding reaction balance does not show what is actually happening to the metal (i.e. the reaction mechanism). The reaction does not occur by a direct reaction between oxygen and iron atoms such as in a combustion reaction, but by electron transfer from the metal to water. This type of reaction is called a redox reaction. In this reaction, one of the reactants is reduced (gains an electron), and another one is oxidized. It's the same process that drives those digital clocks that run on a potato with an iron and copper electrode stuck in them.

The half-reactions of the redox reaction give a more accurate description of the reaction mechanism. The iron is first oxidized to Fe2+ (ferrous ion):

     Fe -> Fe2+ + 2 e-

The ferrous ion is further oxidized to Fe3+, ferric ion:

     Fe2+ -> Fe3+ + e-

The electrons that were produced by the oxidation steps are used in the reduction reaction of water:

     O2 + 2 H2O + 4 e- -> 4 OH-

Combining the above reactions, and balancing them for the number of electrons being transferred, we get:

     4 Fe + 3 O2 + 6 H2O -> 4 Fe3+ + 12 OH-
however, these free ferric and hydroxide ions are not actual intermediates for the reaction, but directly form a more stable complex, under the liberation of water:
                         -> 2 Fe2O3 + 6 H2O

Thus summarizing, for a corrosion reaction we need (1) a metal that can be oxidized, (2) oxygen, and (3) water. The reaction can be facilitated by adding a salt to the water (such as sodium chloride, sea salt). The salt increases the conductivity of the water, and thus enhances the electron transfer. This is the reason why cars rust so much faster in the winter (plenty of water, salt on the roads). Another way to enhance the corrosion of metals is to increase the acidity of the solution; the increased availability of H+ ions not only increases conductivity, but also promotes the reduction reaction. Finally, temperature is also a factor: at higher temperatures metals corrode faster.

Some metals corrode more easily than others. This is a function of their redox potential, or their ability to donate electrons. Whether they have a high redox potential because they can give up electrons easily or give up electrons easily because of their redox potential is a chicken and egg question. In any case, materials such as magnesium, zinc, aluminum, and chrome corrode more easily than iron. Materials such as tin, lead, copper, silver and gold corrode less easily than iron.

In case you noticed that aluminum was in the list of easily corroding materials, this is no mistake. However, this material has the pleasant property that its oxide (aluminum oxide) forms a protective layer around the aluminum, so that no more oxygen can permeate. Hence, many people are under the somewhat incorrect impression that aluminum doesn't "rust"...

... which brings us to the final point: how to control corrosion. One option would be to keep the metal dry and/or free from oxygen. This is not always an option, so metals are often coated with paint, plastic, grease, or any other barrier that keeps out water or oxygen. This is often a problem when the barrier gets scratched or wears off; in this case water can get trapped underneath, and corrode the metal even faster.

One successful method for corrosion control is by using a sacrificial metal, which is a metal that corrodes more easily. For instance, the redox potentials for iron and zinc, and tin are:

     Fe -> Fe2+ + 2 e-      0.44 V
     Zn -> Zn2+ + 2 e-      0.76 V

     Sn -> Sn2+ + 2 e-      0.14 V

Because zinc (Zn) has a higher redox potential than iron (Fe), this material will corrode if both materials are submerged in water. Thus, zinc is a good coating material for iron, and even inhibits rusting of iron when the coating is damaged. Often, iron and aluminum ships have blocks of zinc or magnesium tied to the hull to act as sacrificial metal. Another name for this method is cathodic protection.

Note that tin (Sn) has a lower redox potential than iron. This material is also often used as an oxygen barrier for iron. However, if this coating is damaged, the iron is preferentially oxidized over the tin. As a result, the iron rusts more readily. Thus, if you want to keep that 1980 Chevy Impala running throughout the harsh New England winters, it's better to coat the bottom with zinc spray than with tin.


Sources:

chemistry, years of it.
http://www.terrific-scientific.co.uk/Topics/Corrosion
http://www.corrosioncontrol.biz/Rust.htm
http://www.corrosionsource.com/cost/CorrosionCostUS.htm