Where a moist wind is blown towards a mountainside, the wind rises and cools on the windward side of the mountain. As it cools, the air can reach its dew point, causing moisture in the air to condense and form clouds, frequently with rain. As the water vapour condenses and forms the cloud, latent heat is released by the water vapour into the air.
This only occurs in a stable atmosphere – if the atmosphere were unstable, the air would continue to rise and cumuliform clouds with thunderstorms would likely form.
As this air travels over the top of the mountain, it has become dry (after losing moisture as cloud & rain) and warm (from the release of latent heat). Descending down the far side of the mountain, the air compresses and warms further – so the result is a warm, dry wind.
This is known as a Fohn Wind and it often occurs where the wind has been blowing across the ocean and reaches a mountain range close to the coast, such as in some parts of the Alps.