Gaseous exchange occurs in the alveoli by simple diffusion. The blood flowing past the alveoli is rich in carbon dioxide and very poor in oxygen. The gas molecules naturally flow in the direction of lower concentration through the thin gas exchange membrane, which is only two cells thick.
Alveoli are tiny balloon-like structures that inflate with each inhalation. The membranes that surround these tiny sacs are only one cell thick, and they are coated with a special fluid to enable inflation and dissolve gases. This fluid contains a substance that reduces the surface tension, which could otherwise cause the alveoli to collapse. The sacs have tiny blood vessels in direct contact with them, and these blood vessels also have walls that are only one cell thick.
The alveoli are inflated when the diaphragm contracts and expands the chest cavity. This causes the pressure in the alveoli to drop below atmospheric pressure and air to rush in to inflate them. However, the mix of gases in the lungs is very different than the mix in air because the lungs are constantly releasing carbon dioxide. The body is constantly consuming oxygen and creating carbon dioxide through metabolic processes, and the lungs do not completely empty on exhalation.