The lung is the essential respiration organ in air-breathing animals, including most tetrapods, a few fish and a few snails. The most primitive animals with a lung are the lungfish (vertebrate) and the pulmonate snails (invertebrate). In mammals and the more complex life forms, the two lungs are located in the chest on either side of the heart. Their principal function is to transport oxygen from the atmosphere into the bloodstream, and to release carbon dioxide from the bloodstream into the atmosphere. This exchange of gases is accomplished in the mosaic of specialized cells that form millions of tiny, exceptionally thin-walled air sacs called alveoli.
Medical terms related to the lung often begin with pulmo-, from the Latin pulmonarius ("of the lungs"), or with pneumo- (from Greek πνεύμω "breath")
The lungs are very important. Energy production to aerobic respiration requires oxygen and glucose and produces carbon dioxide as a gaseous waste product, creating a need for an efficient means of oxygen delivery to cells and excretion of carbon dioxide from cells. In small organisms, such as single-celled bacteria, this process of gas exchange can take place entirely by simple diffusion. In larger organisms, this is not possible; only a small proportion of cells are close enough to the surface for oxygen from the atmosphere to enter them through diffusion. Two major adaptations made it possible for organisms to attain great multicellularity: an efficient circulatory system that conveyed gases to and from the deepest tissues in the body, and a large, internalized respiratory system that centralized the task of obtaining oxygen from the atmosphere and bringing it into the body, whence it could rapidly be distributed to all the circulatory system. The lungs also protect the heart from damage to a certain degree.
In air-breathing vertebrates, respiration occurs in a series of steps. Air is brought into the animal via the airways — in reptiles, birds and mammals this often consists of the nose; the pharynx; the larynx; the trachea (also called the windpipe); the bronchi and bronchioles; and the terminal branches of the respiratory tree. The lungs of mammals are a rich lattice of alveoli, which provide an enormous surface area for gas exchange. A network of fine capillaries allows transport of blood over the surface of alveoli. Oxygen from the air inside the alveoli diffuses into the bloodstream, and carbon dioxide diffuses from the blood to the alveoli, both across thin alveolar membranes.
The drawing and expulsion of air is driven by muscular action; in early tetrapods, air was driven into the lungs by the pharyngeal muscles, whereas in reptiles, birds and mammals a more complicated musculoskeletal system is used. In the mammal, a large muscle, the diaphragm (in addition to the internal intercostal muscles) drives ventilation by periodically altering the intra-thoracic volume and pressure; by increasing volume and thus decreasing pressure, air flows into the airways down a pressure gradient, and by reducing volume and increasing pressure, the reverse occurs. During normal breathing, expiration is passive and no muscles are contracted (the diaphragm relaxes).
Another name for this inspiration and expulsion of air is ventilation. Vital capacity is the maximum volume of air that a person can exhale after maximum inhalation. A person's vital capacity can be measured by a spirometer (spirometry). In combination with other physiological measurements, the vital capacity can help make a diagnosis of underlying lung disease.