With over 32,000 extant species 1 , teleost fishes comprise the majority of vertebrate species. Their taxonomic diversity is matched by extensive genetic and phenotypic variation, including novel immunological strategies. Although the functionality of the adaptive immune system has been considered to be conserved since its emergence in the ancestor of all jawed vertebrates 2,3 , fundamental modifications of the immune gene repertoire have recently been reported in teleosts [4][5][6][7] . One of the most dramatic changes has occurred in Atlantic cod (Gadus morhua), involving complete loss of the MHC II pathway that is otherwise responsible for the detection of bacterial pathogens in vertebrates 4 . Moreover, this loss is accompanied by a substantially enlarged repertoire of MHC I genes, which normally encode molecules for protection against viral pathogens. It has thus been hypothesized that the expanded MHC I repertoire of cod evolved as a compensatory mechanism, whereby broader MHC I functionality makes up for the initial loss of MHC II (refs. 4,6). However, the questions of how and when MHC II was lost relative to the MHC I expansion, and whether these genomic modifications are causally related, have so far remained unresolved.As key components of the vertebrate adaptive immune system, the complex MHC pathways and their functionality are now well characterized 8-10 , but less is known about the causes of MHC copy number variation, which poses an immunological tradeoff 11,12 . Although an increase in the number of MHC genes facilitates pathogen detection, it will also decrease the number of circulating T cells [13][14][15][16] , resulting in an immune system that can detect a large number of pathogens at the expense of being less efficient in removing them. The evolution of MHC copy numbers is therefore likely driven toward intermediate optima determined by a tradeoff between detection and elimination of pathogens-as suggested by selection for 5-10 copies inferred in case studies of fish 17,18 and birds 19 . Because pathogen load and the associated selective pressures vary between habitats, the optimal number of MHC copies depends on the environment [20][21][22] . As a result, interbreeding between different locally adapted populations is expected to produce hybrids with excess (above optimal) MHC diversity that are characterized by T cell deprivation and low fitness. This process would introduce postzygotic reproductive isolation and promote reinforcement of premating isolation between the populations. Consequently, MHC genes have been suggested to have an important role in speciation 22,23 , but, to our knowledge, this role has never been tested comparatively in a macroevolutionary context.Here we report comparative analyses of 76 teleost species, of which 66 were sequenced to produce partial draft genome assemblies, including 27 representatives of cod-like fishes within the order Gadiformes. First, we use phylogenomic analysis to resolve standing controversy regarding early-teleost divergences and to firmly ...