An atmosphere (from Ancient Greek ἀτμός (atmós) 'vapour, steam', and σφαῖρα (sphaîra) 'sphere')  is a layer of gas or layers of gases that envelop a planet, and is held in place by the gravity of the planetary body. A planet retains an atmosphere when the gravity is great and the temperature of the atmosphere is low. A stellar atmosphere is the outer region of a star, which includes the layers above the opaque photosphere; stars of low temperature might have outer atmospheres containing compound molecules.
The atmosphere of Earth is composed of nitrogen (78%), oxygen (21%), argon (0.9%), carbon dioxide (0.04%) and trace gases.  Most organisms use oxygen for respiration; lightning and bacteria perform nitrogen fixation to produce ammonia that is used to make nucleotides and amino acids; plants, algae, and cyanobacteria use carbon dioxide for photosynthesis. The layered composition of the atmosphere minimises the harmful effects of sunlight, ultraviolet radiation, the solar wind, and cosmic rays to protect organisms from genetic damage. The current composition of the atmosphere of the Earth is the product of billions of years of biochemical modification of the paleoatmosphere by living organisms. Evolution of the Atmosphere
The initial gaseous composition of an atmosphere is determined by the chemistry and temperature of the local solar nebula from which a planet is formed, and the subsequent escape of some gases from the interior of the atmosphere proper. The original atmosphere of the planets originated from a rotating disc of gases, which collapsed onto itself and then divided into a series of spaced rings of gas and matter that, which later condensed to form the planets of the Solar System. The atmospheres of the planets Venus and Mars are principally composed of carbon dioxide and nitrogen, argon and oxygen. 
The composition of Earth's atmosphere is determined by the by-products of the life that it sustains. Dry air (mixture of gases) from Earth's atmosphere contains 78.08% nitrogen, 20.95% oxygen, 0.93% argon, 0.04% carbon dioxide, and traces of hydrogen, helium, and other "noble" gases (by volume), but generally a variable amount of water vapor is also present, on average about 1% at sea level. 
The low temperatures and higher gravity of the Solar System's giant planets— Jupiter, Saturn, Uranus and Neptune—allow them more readily to retain gases with low molecular masses. These planets have hydrogen–helium atmospheres, with trace amounts of more complex compounds.
Two satellites of the outer planets possess significant atmospheres. Titan, a moon of Saturn, and Triton, a moon of Neptune, have atmospheres mainly of nitrogen. When in the part of its orbit closest to the Sun, Pluto has an atmosphere of nitrogen and methane similar to Triton's, but these gases are frozen when it is farther from the Sun.
Other bodies within the Solar System have extremely thin atmospheres not in equilibrium. These include the Moon ( sodium gas), Mercury (sodium gas), Europa (oxygen), Io ( sulfur), and Enceladus ( water vapor).
The first exoplanet whose atmospheric composition was determined is HD 209458b, a gas giant with a close orbit around a star in the constellation Pegasus. Its atmosphere is heated to temperatures over 1,000 K, and is steadily escaping into space. Hydrogen, oxygen, carbon and sulfur have been detected in the planet's inflated atmosphere. 
The atmosphere of Earth is composed of layers with different properties, such as specific gaseous composition, temperature, and pressure.
The troposphere is the lowest layer of the atmosphere. This extends from the planetary surface to the bottom of the stratosphere. The troposphere contains 75-80 per cent of the mass of the atmosphere,  and is the atmospheric layer wherein the weather occurs; the height of the troposphere varies between 17km at the equator and 7.0km at the poles.
The stratosphere extends from the top of the troposphere to the bottom of the mesosphere, and contains the ozone layer, at an altitude between 15km and 35km. It is the atmospheric layer that absorbs most of the ultraviolet radiation that Earth receives from the Sun.
The thermosphere extends from an altitude of 85km to the base of the exosphere at 690km and contains the ionosphere, where solar radiation ionizes the atmosphere. The density of the ionosphere is greater at short distances from the planetary surface in the daytime and decreases as the ionosphere rises at night-time, thereby allowing a greater range of radio frequencies to travel greater distances. Moreover, located in the thermosphere is the Kármán line at 100km, which is the boundary between outer space and Earth's atmosphere.
Atmospheric pressure is the force (per unit-area) perpendicular to a unit-area of planetary surface, as determined by the weight of the vertical column of atmospheric gases. In said atmospheric model, the atmospheric pressure, the weight of the mass of the gas, decreases at high altitude because of the diminishing mass of the gas above the point of barometric measurement. The units of air pressure are based upon the standard atmosphere (atm), which is 101.325 kPa (760 Torr, or 14.696 pounds per square inch (psi). The height at which the atmospheric pressure declines by a factor of e (an irrational number equal to 2.71828) is called the scale height (H). For an atmosphere of uniform temperature, the scale height is proportional to the atmospheric temperature, and is inversely proportional to the product of the mean molecular mass of dry air, and the local acceleration of gravity at the point of barometric measurement.
Surface gravity differs significantly among the planets. For example, the large gravitational force of the giant planet Jupiter retains light gases such as hydrogen and helium that escape from objects with lower gravity. Secondly, the distance from the Sun determines the energy available to heat atmospheric gas to the point where some fraction of its molecules' thermal motion exceed the planet's escape velocity, allowing those to escape a planet's gravitational grasp. Thus, distant and cold Titan, Triton, and Pluto are able to retain their atmospheres despite their relatively low gravities.
Since a collection of gas molecules may be moving at a wide range of velocities, there will always be some fast enough to produce a slow leakage of gas into space. Lighter molecules move faster than heavier ones with the same thermal kinetic energy, and so gases of low molecular weight are lost more rapidly than those of high molecular weight. It is thought that Venus and Mars may have lost much of their water when, after being photodissociated into hydrogen and oxygen by solar ultraviolet radiation, the hydrogen escaped. Earth's magnetic field helps to prevent this, as, normally, the solar wind would greatly enhance the escape of hydrogen. However, over the past 3 billion years Earth may have lost gases through the magnetic polar regions due to auroral activity, including a net 2% of its atmospheric oxygen.  The net effect, taking the most important escape processes into account, is that an intrinsic magnetic field does not protect a planet from atmospheric escape and that for some magnetizations the presence of a magnetic field works to increase the escape rate. 
Other mechanisms that can cause atmosphere depletion are solar wind-induced sputtering, impact erosion, weathering, and sequestration—sometimes referred to as "freezing out"—into the regolith and polar caps.
Atmospheres have dramatic effects on the surfaces of rocky bodies. Objects that have no atmosphere, or that have only an exosphere, have terrain that is covered in craters. Without an atmosphere, the planet has no protection from meteoroids, and all of them collide with the surface as meteorites and create craters.
Wind erosion is a significant factor in shaping the terrain of rocky planets with atmospheres, and over time can erase the effects of both craters and volcanoes. In addition, since liquids can not exist without pressure, an atmosphere allows liquid to be present at the surface, resulting in lakes, rivers and oceans. Earth and Titan are known to have liquids at their surface and terrain on the planet suggests that Mars had liquid on its surface in the past.
Main article: Extraterrestrial atmosphere
The circulation of the atmosphere occurs due to thermal differences when convection becomes a more efficient transporter of heat than thermal radiation. On planets where the primary heat source is solar radiation, excess heat in the tropics is transported to higher latitudes. When a planet generates a significant amount of heat internally, such as is the case for Jupiter, convection in the atmosphere can transport thermal energy from the higher temperature interior up to the surface.
From the perspective of a planetary geologist, the atmosphere acts to shape a planetary surface. Wind picks up dust and other particles which, when they collide with the terrain, erode the relief and leave deposits ( eolian processes). Frost and precipitations, which depend on the atmospheric composition, also influence the relief. Climate changes can influence a planet's geological history. Conversely, studying the surface of the Earth leads to an understanding of the atmosphere and climate of other planets.