The atmosphere is heated by several complex processes, but the source of nearly all atmospheric heating is the sun. Locally, air may be heated by processes that do not rely directly on the sun, such as volcanic eruptions, lightning strikes, forest fires or human activity, such as power generation and heavy industry, but these heat sources are insignificant compared to solar radiation.
The Sun
The sun radiates energy in all directions in the form of heat, light and radiation. This energy is capable of heating objects across incredible distances. Solar heating occurs when solar radiation strikes a molecule of some material and is absorbed. Solar radiation strikes reflective materials and reflect it away without absorbing much heat. Transparent materials allow solar radiation to pass through without heat being exchanged.
The Atmosphere
The earth's atmosphere is either reflective or transparent, depending on the wavelength of the radiation it encounters. As a result, the atmosphere receives little direct heat from solar radiation. Solar energy is either reflected back into space or allowed to pass through without its energy being absorbed. More energy is reflected by clouds and chemical compounds, such as ozone. Only about 54 percent of the sun's energy passes through the atmosphere to reach the surface.
The Earth
Once solar radiation reaches the earth's surface, the ground and bodies of water absorbs nearly all of it. Only about 4 percent is reflected back into space. By absorbing solar energy, these surfaces heat up. Warm objects begin to radiate long-wave infrared radiation. Without the atmosphere, this energy would radiate out into space.
The Greenhouse Effect
Due to the chemical composition of the earth's atmosphere, most of the infrared radiation emitted by the warm surface never reaches space. Instead the radiation is reflected or absorbed by compounds known as greenhouse gasses. When these compounds absorb the infrared radiation from the surface, the atmosphere heats up. The energy reflected back toward the earth warms the surface further, causing the earth to emit more infrared radiation. This creates a cycle that keeps the atmosphere and the surface warm.
References