A fish breathes through its gills, extracting oxygen from the water. Other sea animals, such as whales, breathe oxygen from the air because they are mammals.
Gills work much the same way as lungs; both have small blood vessels that the gases filter through. However, because water contains less oxygen than air, fish have a harder time extracting oxygen from it. Fish actually breathe the O2 dissolved in water, not the oxygen that is bound to hydrogen in a water molecule, according to the How Stuff Works website. By volume, air has about 20 times more oxygen than water, which is why some fish, mammals, breathe oxygen from the surface air rather than trying to extract it from the water.