BackgroundAlthough bats are natural reservoirs of many pathogens, few studies have been conducted on the genetic variation and detection of selection in major histocompatibility complex (MHC) genes. These genes are critical for resistance and susceptibility to diseases, and host–pathogen interactions are major determinants of their extensive polymorphism. Here we examined spatial patterns of diversity of the expressed MHC class II DRB gene of three sympatric Neotropical bats, Carollia perspicillata and Desmodus rotundus (Phyllostomidae), and Molossus molossus (Molossidae), all of which use the same environments (e.g., forests, edge habitats, urban areas). Comparison with neutral marker (mtDNA D-loop) diversity was performed at the same time.ResultsTwenty-three DRB alleles were identified in 19 C. perspicillata, 30 alleles in 35 D. rotundus and 20 alleles in 28 M. molossus. The occurrence of multiple DRB loci was found for the two Phyllostomidae species. The DRB polymorphism was high in all sampling sites and different signatures of positive selection were detected depending on the environment. The patterns of DRB diversity were similar to those of neutral markers for C. perspicillata and M. molossus. In contrast, these patterns were different for D. rotundus for which a geographical structure was highlighted. A heterozygote advantage was also identified for this species. No recombination or gene conversion event was found and phylogenetic relationships showed a trans-species mode of evolution in the Phyllostomids.ConclusionsThis study of MHC diversity demonstrated the strength of the environment and contrasting pathogen pressures in shaping DRB diversity. Differences between positively selected sites identified in bat species highlighted the potential role of gut microbiota in shaping immune responses. Furthermore, multiple geographic origins and/or population admixtures observed in C. perspicillata and M. molossus populations acted as an additional force in shaping DRB diversity. In contrast, DRB diversity of D. rotundus was shaped by environment rather than demographic history.Electronic supplementary materialThe online version of this article (doi:10.1186/s12862-016-0802-1) contains supplementary material, which is available to authorized users.