The major histocompatibility complex (MHC) genes code for the proteins responsible for pathogen recognition. The MHC class II DRB gene is multiplicated in the bank vole, Myodes glareolus, with different numbers of loci found in different individuals. Possessing large numbers of loci should increase the probability of pathogen recognition, but according to the optimality hypothesis, there is a cost of possessing too many MHC alleles. Using 454 technology, we determined the individual DRB allelic diversity and related it to the load of intestinal parasites in voles collected from three sites separated by a distance of 12 to 27 km. The analysis of six microsatellite loci revealed significant population structure (F(ST) = 0.07). The sites differed significantly in the prevalence and abundance of nematode species as well. We found two significant associations between MHC alleles and the intensity of the infection with the most prevalent nematode, Aspiculuris tetraptera. One of these associations was population-specific. This result suggests that the directions of selection can differ between populations connected by a low level of gene flow, which may contribute to the maintenance of high DRB allele diversity. In accordance with the optimality hypothesis, individuals with an intermediate number of alleles carried the lowest number of nematode species and had the lowest prevalence of A. tetraptera. However, the intensity of infection with A. tetraptera was linearly and negatively associated with the number of alleles.