To explain the long-term persistence of polymorphic alleles (trans-specific polymorphism) at the major histocompatibility complex (MHC) loci in rodents and primates, a computer simulation study was conducted about the coalescence time of different alleles sampled under various forms of selection. At the same time, average heterozygosity, the number of alleles in a sample, and the rate of codon substitution were examined to explain the mechanism of maintenance of polymorphism at the MHC loci. The results obtained are as follows. (1) The coalescence time for neutral alleles is too short to explain the trans-specific polymorphism at the MHC loci. (2) Under overdominant selection, the coalescence time can be tens of millions of years, depending on the parameter values used. The average heterozygosity and the number of alleles observed are also high enough to explain MHC polymorphism. (3) The pathogen adaptation model proposed by Snell is incapable of explaining MHC polymorphism, since the coalescence time for this model is too short and the expected heterozygosity and the expected number of alleles are too small. (4) From the mathematical point of view, the minority advantage model of frequency-dependent selection is capable of explaining a high degree of polymorphism and trans-specific polymorphism. (5) The molecular mimicry hypothesis also gives a sufficiently long coalescence time when the mutation rate is low in the host but very high in the parasite. However, the expected heterozygosity and the expected number of alleles tend to be too small. (6) Consideration of the molecular mechanism of the function of MHC molecules and other biological observations suggest that the most important factor for the maintenance of MHC polymorphism is overdominant selection. However, some experiments are necessary to distinguish between the overdominance and frequency-dependent selection hypotheses.