Since whales are mammals, they must breathe out of the water, like humans. Their respiratory system therefore functions similarly to that of land mammals, but has adaptations specific to their underwater environment.
When the animal inhales, air passes through the blowhole, nasal duct, larynx, trachea, and lastly the lungs. Same thing when it exhales, only in reverse! In large rorquals, the inhale-exhale cycle takes just a second or two. Additionally, whales have the ability to renew 90% of the air in their lungs with each breath. By comparison, in humans this figure is only 10 to 15%.