The transfer of gases between an organism and the external environment in either direction. It occurs by diffusion across a concentration gradient and includes the exchange of oxygen and carbon dioxide in respiration and photosynthesis. Successful gaseous exchange requires a large surface area, as is provided by the alveoli of the lungs and the leaves of plants.