During inhalation, the intercostal muscles contract causing the rib cage to move up and out. The diaphragm also contracts and flattens. This causes the thorax to expand, increasing the volume and decreasing the pressure in the lungs to below the pressure of the atmosphere. This causes air to move into the lungs down the pressure gradient. To exhale, the diaphragm and intercostal muscles relax, causing the rib cage to move down and in. This decreases the volume of the thorax and increases the pressure, forcing the air back out of the lungs.