If you don't count the sparse upper regions that arguably extend halfway to the moon and gradually dissipate into space, Earth's atmosphere is thin. It extends about 1000 kilometers (621 miles) from the ground to the top of the thermosphere. Within that delicate, life-nurturing blanket are four distinct regions: the troposphere, the stratosphere, the mesosphere and the thermosphere. Each region features a distinct temperature gradient, and in two of them, the gradient is negative, meaning that temperatures decrease with altitude. These two regions are the troposphere and the mesosphere.
TL;DR (Too Long; Didn't Read)
Temperature decreases with altitude in two of Earth's atmospheric regions: the troposphere and the mesosphere. The troposphere is the region closest to the ground, and the mesosphere is just above the ozone layer.
The Troposphere – Where Weather Happens
Extending from the ground to an altitude of about 10 km (6.2 miles; 33,000 feet), the troposphere is just thick enough to envelop Mount Everest. It contains about 75 percent of the air and 99 percent of the water vapor in the atmosphere. Its density is highest at the boundary layer, where the atmosphere meets the ground, and lowest at the tropopause, where the stratosphere begins.
Temperatures decrease with altitude in the troposphere at a rate of about 6.5 degrees Celsius (11.7 degrees Fahrenheit) per kilometer, depending on the weather. This occurs as a result of decreasing air pressure with altitude. As pressure decreases, air expands, and it cools as it does so. Conforming to this gradient, the temperature at the tropopause is, on average, about 65 C (117 F) colder than at the boundary layer.
The Mesosphere – Above the Ozone Layer
Because ozone interacts with sunlight, the ozone layer at the top of the stratosphere has a warming effect, and in that layer of the atmosphere, the temperature gradient is positive. However, when you rise above the ozone layer and enter the mesosphere, the gradient again becomes negative.
The mesosphere extends from altitudes of about 50 km (31 mi) to 85 km (53 mi). In this layer, the air pressure is only about 1 percent of what it is at sea level, but that is still enough air to burn up meteors. At the top of the mesosphere – the mesopause – scientists have recorded the coldest temperatures in the atmosphere. They are around -90 C (-130 F).
Off Into Space
In the top layer of the atmosphere, the thermosphere, temperatures again rise with altitude due to absorption of ultraviolet sunlight. At the top of this layer, temperatures can vary from 500 C (932 F) to 2,000 C (3,632 F) or higher. The high energy radiation from the sun ionizes particles in this layer, and for this reason, it's sometimes referred to as the ionosphere. It's the layer in which the auroras occur.
Some scientists identify a fifth layer that begins above the thermosphere and extends from 100,000 to 200,000 km (62,000 to 120,000 mi) into space. In this layer, called the exosphere, the air density gradually trails off to nothing. Although there is no clear gradient, temperatures can vary from 0 C (32 F) to 1,700 C (3,092 F) depending on whether it's day or night, The concentration of particles is too low to conduct heat, however.