Gas exchange occurs when oxygen and carbon dioxide diffuse across the alveolar capillary barrier. Oxygen diffuses from the alveoli into the blood, while carbon dioxide diffuses from the blood into the alveoli to be exhaled. The thin structure of the barrier facilitates this efficient exchange.