The temperature of atmospheric layers is determined by air composition, movement, and density of each layer. In the troposphere, for example, it is warmer at the base layer because the air absorbs heat from the earth's surface. Because air density decreases with height, temperature also decreases.
In the stratosphere, the amount of water vapor decreases while ozone concentration increases with height. This brings about an increase in temperature because ozone formation produces heat and the ozone molecules absorb the ultraviolet rays of the sun.
Moving upward from the stratosphere to the mesosphere, oxygen molecules become less dense, and so the warm temperature begins to drop again with the increase in altitude. The temperature is coldest in this layer; it reaches -90 to -120 degrees Celsius.
In the thermosphere, temperature goes up to 2,000 degrees Celsius with the increase in altitude because molecules absorb high-intensity x-ray and ultraviolet rays from the sun. Surprisingly, air temperature in this layer feels cold to the skin because air density is very low. Astronauts in space prefer to stay in orbit in this layer. Air in the exosphere is too thin to warm up and the molecules escape to outer space. The temperature in some parts of space can be very hot, however, because of the solar wind.