Major histocompatibility complex (MHC) molecules mediate the adaptive immune response against pathogens. Certain MHC alleles are generalists: they present an exceptionally large variety of antigenic peptides. However, the functional implications of such elevated epitope binding promiscuity in the MHC molecules are largely unknown. According to what we term the pathogen-driven promiscuity hypothesis, exposure to a broad range of pathogens favors the evolution of highly promiscuous MHC variants. Consistent with this hypothesis, we found that in pathogen-rich geographical regions, humans are more likely to carry promiscuous MHC class II DRB1 alleles, and the switch between high and low promiscuity levels has occurred repeatedly and in a rapid manner during human evolution. We also show that selection for promiscuous peptide binding shapes MHC genetic diversity. In sum, our study offers a conceptually novel mechanism to explain the global distribution of allelic variants of a key human immune gene by demonstrating that pathogen pressure maintains promiscuous MHC class II alleles. More generally, our work highlights the hitherto neglected role of epitope binding promiscuity in immune defense, with implications for medical genetics and epidemiology.