According to Climate Education for K-12 from North Carolina State University, air pressure decreases as elevation increases in higher levels of the atmosphere. The atmosphere has four levels. From the closest level to the surface of the earth to the highest level, they are as follows: the troposphere, the stratosphere (where the ozone layer lies), the mesosphere and the thermosphere.
There is a general decrease in temperature as elevation rises, contributing to the reduction of air pressure. However, although the thermosphere is hot, the layer is very thin, so the air pressure is still lower than in the other levels. Gravity in the earth's surface pulls air molecules closer to the ground and makes air pressure near the surface greater than at the above levels. Air pressure is a measure of the weight of air molecules from above, so at higher altitudes, the weight of an object is lower; thus, the air pressure is lower. The reason temperature has an effect on air pressure is that warmer air has molecules that move closer together. As warm air rises above cooler air in the atmosphere, the air molecules spread out while they cool. As a result, the air pressure is reduced.