Birds have specially adapted respiratory systems that allow them to take in more oxygen and release heat more quickly than any other air-breathing vertebrate. These systems appear to have originally evolved to allow for dinosaurs to gain very large sizes while remaining active, but have adapted very well to support flight.
Most terrestrial animals -- including mammals -- have tidal lungs; these are lungs that are basically just sacs of air that shrink and expand to pump air in and out. These work okay, but it means that the lungs spend a fair amount of time mostly empty, and on top of this there is a lot of carbon dioxide and other wastes hanging around that never get completely pushed out of the lungs (when a lung does manage to push all the air out, that is a collapsed lung, and can be fatal).
In contrast to this, birds' lungs are a series of parallel chambers, called the parabronchi, that sit between many sacs of air.1 The sacs pump like lower invertebrates' lungs, shrinking and expanding, while the parabronchi do not. While this seems like a small change, it means that the air that sits in the air sacs remains fresh: while mammalian lungs are filled with a puddle of deoxygenated air that is never fully expelled from the lungs, avian lungs are only filled with oxygen-rich air stored in their air sacs. While some air does remain in the air sacs after exhalation, oxygen is not being removed and it remains 'fully charged' with the same oxygen content as atmospheric air2.
This system requires some anatomical adjustments; birds do not use a diaphragm to help them pump air, as the air sacs are spread throughout the chest cavity. Instead the chest cavity expands and contracts, pumping the entire sternum in and out. Birds also have hollow, pneumatized bones that connect to the air sacks. We don't know exactly why birds have these, but they are used as added storage capacity to the air sacs.3
Modern birds usually have nine air sacs surrounding the lungs. One breath will take in fresh air into the posterior air sacs and move deoxygenated air from the parabronchi to the anterior air sacs; on exhalation air moves from the posterior sacs to the parabronchi, and the anterior air sacs empty through the trachea to the outside. The full cycle of air through this system takes two full breaths.
But why store deoxygenated air in the anterior air sacs? Because this allows air to travel through the parabronchi on both inhalation and exhalation. During inhalation the valve between the trachea and the anterior air sacs is closed, and fresh air is taken into the posterior air sacs, the air that was in the posterior sacs is pulled into the parabronchi, and the air in the parabronchi is pulled into the anterior sacs. On exhalation, the valve from the trachea to the posterior sacs is closed, and air is pushed from the posterior sacs through the parabronchi, through the anterior sacs, and out the trachea. The air keeps moving through the cycle, never allowing deoxygenated air to recirculate in the system.
Parabronchi don't look much like mammalian bronchi; multiple parabronchi run in parallel, and unlike in mammals they don't branch and re-branch. Birds have no alveoli, but instead have a hedgehog bush of microscopic tubules called 'air capillaries' in which blood and air exchange O2 and CO2. These capillaries are 10 to 100 times smaller than our alveoli, providing a greater surface area for gas exchange.
Because birds have linear lungs rather than bags, it was long assumed that they would be able to perform another trick to maximize oxygen uptake: countercurrent gas exchange. This simply means that the oxygenated air flows in the opposite direction from the incoming deoxygenated blood. This would maximize oxygen uptake.4 However, we have not yet caught any bird doing this; instead they use a cross-current system, in which the capillaries carrying blood flow at an angle across the parabronchi. This is more efficient than the mammalian system, as it means that the blood flowing past the parabronchi is constantly in contact with oxygen-rich air, but is less efficient than gills. It is a bit of a mystery as to why birds didn't ever make this optimization, but it is apparent that they are able to survive without it.
It is -- unsurprisingly -- difficult to make accurate observations of the internal processes of a bird in its natural habitat, and we are only just nailing down the standard processes of avian respiration and circulatory systems. Unfortunately, this means that there is some misinformation about how these processes work, and some questions that haven't yet been fully answered.
1. This system was originally developed in the dinosaurs, being common throughout the saurischia, and is one thing that allowed sauropods and T. Rexes to get bigger than land mammals can get today. Both the increased oxygen intake and the honeycombing of bones to allow for lighter weight and better heat exchange supported larger growth. A similar sort of development occurred in most of the early Archosauria, including the reptiles. Many reptiles, including alligators and crocodiles, have unidirectional airflow through a pair of bronchi, but without the air sacs.
2. Because nature is a grab-bag of whatever works, things are slightly more complex than this. In this essay I am refering specifically to paleopulmonic-parabronchi, the large parabronchi that do most of the work. Some birds (e.g., emu, ducks, grebes, and loons) also have neopulmonic-parabronchi, which do allow for bidirectional airflow. These sit just in front of the posterior air sacs, and take some oxygen from the air on both inspiration and exhalation just before the air enters the primary, paleopulmonic-parabronchi. In all birds, this is a comparatively minor source of oxygen.
3. Well, we do known why birds have these: many dinosaurs needed them to help them grow very big without becoming too heavy to move. Birds inherited the tendency to fill their bones with air pockets from the dinosaurs, but have evolved a lot since then. We are still figuring out what-all these air pockets do in modern animals, but they appear to serve multiple functions -- they add to the air capacity of the air sacs, they allow for more variation in skeletal structures, they increase heat exchange with external air, and they may sometimes (but not always) make birds lighter. Some birds, including, unsurprisingly all diving birds, have lost much of their skeletal pneumatization.
I should perhaps note that the technical term for these bone structures is "postcranial skeletal pneumaticity", as many animals, including humans, have cranial pneumatic bones: we call them sinuses.
4. Countercurrent exchange is a highly efficient way of getting oxygen into the blood, and is present in aquatic gills and perhaps some reptile lungs. A more technical elaboration is that countercurrent oxygen exchange produces a reversal of the gradient in partial pressure of the dissolved respiratory gasses and blood gasses so that the pressure of oxygen in expired water is less than in blood leaving the respiratory organ, and the pressure of carbon dioxide in the expired water is greater than in blood leaving the organ.