The genes of the major histocompatibility complex (MHC) are found in all vertebrates and are an important component of individual fitness through their role in disease and pathogen resistance. These genes are among the most polymorphic in genomes and the mechanism that maintains the diversity has been actively debated with arguments for natural selection centering on either additive or nonadditive genetic effects. Here, we use a quantitative genetics breeding design to examine the genetic effects of MHC class IIB alleles on offspring survivorship in Chinook salmon (Oncorhynchus tshawytscha). We develop a novel genetic algorithm that can be used to assign values to specific alleles or genotypes. We use this genetic algorithm to show simultaneous additive and nonadditive effects of specific MHC class IIB alleles and genotypes on offspring survivorship. The additive effect supports the rare-allele hypothesis as a potential mechanism for maintaining genetic diversity at the MHC. However, contrary to the overdominance hypothesis, the nonadditive effect led to underdominance at one heterozygous genotype, which could instead reduce variability at the MHC. Our algorithm is an advancement over traditional animal models that only partition variance in fitness to additive and nonadditive genetic effects, but do not allocate these effects to specific alleles and genotypes. Additionally, we found evidence of nonrandom segregation during meiosis in females that promotes an MHC allele that is associated with higher survivorship. Such nonrandom segregation could further reduce variability at the MHC and may explain why Chinook salmon has one of the lowest levels of MHC diversity of all vertebrates.