When we breathe in air, it reaches to the lungs via respiratory tract and ultimately to the alveoli of the lungs which are in close vicinity to the tissues. As the alveoli is rich in oxygen and tissues are rich in carbon dioxide(as oxygen is utilized there and carbon dioxide is released as a byproduct ), the gases get exchanged by diffusion along the concentration gradient. So, the gases get interchanged in between the lung and the tissues. The gases gets exchanged within the lung in the same manner i.e. along the concentration gradient by the process of diffusion as the gas entering is rich in oxygen while the one leaving is rich in carbon dioxide.