This is actually caused by a natural property called the adiabatic lapse rate. If you think of the Earth's atmosphere as an ideal gas, then you can approximate its behavior using the ideal gas law.
One simple relationship that you may remember if you have ever studied chemistry is the linear relationship between pressure and temperature in a gas. So as pressure decreases, cooling occurs. Perhaps it may be more intuitive to think of the reverse situation. If you heat a gas then the pressure will increase at the same time the temperature does. The relationship is linear if you use standard metric units. Changes in T and P will also cause a change in volume but we are neglecting that here since we are supposed to be talking about the atmosphere.
As a mass of air moves against a mountain range, the air is forced up, where its pressure decreases. It is possible to calculate the theoretical rate of cooling using calculus and the laws of thermodynamics, but I won't subject you to that against your will. As the air cools, it is able to hold less and less water vapor, so humidity gradually increases. If the air is cooled enough, eventually humidity will reach 100% and condensation will occur. As the water begins to condense, some heat is released, which slows the adiabatic cooling. If you love math you can look this stuff up in your favorite book on physical chemistry.
As liha mentioned, understanding this process is cool because it explains why we find rainforests on one side of a mountain and desert on the other. It also explains why you often see a small cloud covering the top of a mountain on a clear day.
I have heard people who come from more of an earth science background call this phenomenon orographic cooling.
[Editor's note, 2/5/2008: Minor typo and formatting fix.]