The gas exchange (entry of oxygen and exit of carbon dioxide) in the pulmonary alveoli occurs by simple diffusion in favor of the partial pressure gradient
When the oxygen partial pressure in the inhaled air is higher than the oxygen partial pressure of the capillaries of the alveoli the air diffuses to the circulatory system. If the oxygen partial pressure in the air is lower (a rare situation since the blood that reaches the alveoli is venous blood) the oxygen exits the circulatory system. The same is true for carbon dioxide.