The depletion of variation at MHC loci, which play a crucial role in pathogen recognition, has been postulated to be one of important extinction risk factors for endangered populations. Thus, it is important to understand how selection affects the level of polymorphism in these genes when populations undergo a reduction in size. We followed MHC diversity in computer simulations of population bottlenecks. The fates of MHC alleles in the simulations were determined either by drift, or by balancing selection resulting from host-parasite coevolution. We found that the impact of selection on MHC polymorphism in bottlenecked populations was dependent upon the timescales involved. Initially, selection maintained lower number of alleles than drift, but after *40 generations of hosts selection maintained higher MHC diversity, as compared to drift. The adverse effects of decreased MHC polymorphism on population viability may be, to some extent, compensated for if selection helps to retain MHC alleles which show high functional diversity, which should allow protection against a broader range of pathogens. Our simulation shows, however, that the mean divergence of alleles retained under selection in bottlenecked populations is not, on average, significantly higher than the divergence due to drift.