Understanding the genetic basis of adaptation is one of the main enigmas of evolutionary biology. Among vertebrates, hemoglobin has been well documented as a key trait for adaptation to different environments. Here, we investigate the role of hemoglobins in adaptation to ocean depth in the diverse teleost order Gadiformes, with species distributed at a wide range of depths varying in temperature, hydrostatic pressure and oxygen levels. Using genomic data we characterized the full hemoglobin (Hb) gene repertoire for subset of species within this lineage. We discovered a correlation between expanded numbers of Hb genes and ocean depth, with the highest numbers in species occupying shallower, epipelagic regions. Moreover, we demonstrate that the Hb genes have functionally diverged through diversifying selection. Our results suggest that the more variable environment in shallower water has led to selection for a larger Hb gene repertoire and that Hbs have a key role in adaptive processes in marine environments.