If you watch an unborn baby on an ultrasound, you'll see his chest expand and contract as if he were breathing. Unborn babies begin practice respirations at around 9 weeks gestation, but their lungs are not functional until they are born. For the 40 or more weeks of gestation, babies rely on their mothers for oxygen and the removal of carbon dioxide.
The placenta -- a highly vascularized tissue attached to the uterus and the umbilical cord -- acts as your baby's lungs. His actual lungs are filled with amniotic fluid. Maternal vessels bring oxygen-rich blood to the placenta where oxygen and carbon dioxide swap places. Oxygen-rich blood is transported to the baby via the umbilical cord and carbon dioxide is carried through maternal vessels to the lungs where it is exhaled as waste. At about 24 weeks, a substance referred to as "surfactant" begins to build up in a baby's lungs which will allow them to expand and stay open once he is born.
Doctors watch a newborn baby closely in case something is amiss with his breathing. For example, a baby born prematurely may have a condition called respiratory distress syndrome because his lungs have not fully matured. If the baby is born too early, he may require artificial surfactant, steroids and ventilation. RDS rarely occurs in full-term infants.