The Sun, which is the Earth's only external form of heat, emits solar radiation mainly in the form of shortwave visible and ultraviolet (UV) energy. As this radiation travels toward the Earth, 25% of it is absorbed by the atmosphere and 25% is reflected by the clouds back into space. The remaining radiation travels unimpeded to the Earth and heats its surface. The Earth releases a lot of energy it has received from the Sun back to space. However, the Earth is much cooler than the Sun, so the energy re-emitted from the Earth's surface is much weaker, in the form of invisible longwave infrared (IR) radiation, sometimes called heat.
Greenhouse gases like water vapour, carbon dioxide, methane and nitrous oxide trap the infrared radiation released by the Earth's surface. The atmosphere acts like the glass in a greenhouse, allowing much of the shortwave solar radiation to travel through unimpeded, but trapping a lot of the longwave heat energy trying to escape back to space. This process makes the temperature rise in the atmosphere just as it does in the greenhouse. This is the Earth's natural greenhouse effect and keeps the Earth 33C warmer than it would be without an atmosphere, at an average 15C. In contrast, the moon, which has no atmosphere, has an average surface temperature of -18C.
During the last 200 years mankind has been releasing extra quantities of greenhouse gases which are trapping more heat in the atmosphere. Over the same time period the climate of the Earth has warmed, and many scientists now accept that there is a direct link between the man-made enhancement of the greenhouse effect and global warming.