Following the everyday logic, the higher from the earth, the air temperature must be warmer because, on the one hand, the higher the closer to the Sun, and on the other, the warm air from the earth rises up.
Actually the temperature of the air in the mountains determine different factors.
By itself, the air has a very low thermal conductivity, it is bad conductor of heat. Because the sun's rays, passing through it, do not have time to heat up. And hot air on the Ground not from solar radiation and from the fact that the earth's surface and the water shell of the Earth absorb the warmth of the sun and then radiate. This thermal radiation and heats the air.
Thermal radiation coming from the Earth, is able to heat the air to about a height of 15 kilometers. The farther from the earth's surface, the temperature of the air below. This happens, firstly, because heated the earth the air when removing from it cools quickly, and secondly, because in the upper layers of the atmosphere the air is more tenuous than that of the earth. The lower air density, the less heat is transferred. Figuratively it can be explained as follows: the higher the density of the air, the more molecules per unit volume, the faster they move and often face, such as collision, as any friction causes heat. The lower the density of the gas (in our case air), the worse he is able to conduct heat.
On average, the rise in every 1000 meters temperature decreases by 6 degrees Celsius.
The attentive reader will object, but the mountains can also absorb solar radiation and to give it in the form of thermal radiation! All right, you can. But do not forget that the air there is much sparse, and he, as we explained above, heats up very badly. Further, the sun's rays on the surface of the mountain slopes not always fall steeply, as on the earth's surface and at an angle. And besides, the mountains prevent warm dense snow caps, which they covered with white snow simply reflects the sun's rays.
Snow-capped mountains and foothills