In vertebrates, the genes of the major histocompatibility complex (MHC) are among the most debated candidates accounting for co-evolutionary processes of host–parasite interaction at the molecular level. The exceptionally high allelic polymorphism found in MHC loci is believed to be maintained by pathogen-driven selection, mediated either through heterozygous advantage or rare allele advantage (= frequency dependent selection). While investigations under natural conditions are still very rare, studies on humans or mice under laboratory conditions revealed support for both hypotheses. We investigated nematode burden and allelic diversity of a functional important MHC class II gene (DRB exon2) in free-ranging yellow-necked mice (Apodemus flavicollis). Twenty-seven distinct Apfl-DRB alleles were detected in 146 individuals with high levels of amino acid sequence divergence, especially at the antigen binding sites (ABS), indicating selection processes acting on this locus. Heterozygosity had no influence on the infection status (being infected or not), the number of different nematode infections (NNI) or the intensity of infection, measured as the individual faecal egg count (FEC). However, significant associations of specific Apfl-DRB alleles to both nematode susceptibility and resistance were found, for all nematodes as well as in separate analyses of the two most common nematodes. Apodemus flavicollis individuals carrying the alleles Apfl-DRB*5 or Apfl-DRB*15 revealed significantly higher FEC than individuals with other alleles. In contrast, the allele Apfl-DRB*23 showed a significant association to low FEC of the most common nematode. Thus, our results provide evidence for pathogen-driven selection acting through rare allele advantage under natural conditions.