The family Suidae (pigs), mostly wild, and their closest living taxa Tayassuidae (peccaries) play important roles in their natural environment, agriculture and in emerging/zoonotic diseases. The genetics of the immune system of the domestic pig (Sus scrofa) in particular the major histocompatibility complex (MHC) has been extensively studied. However, there is little knowledge of the immunogenetics of wild pigs and peccaries. To address this, we used DNA capture with probes designed from the domestic pig genome to generate MHC genetic resources from 11 wild species and investigated the evolution of class Ia and Ib genes. This method shows relatively good efficiency when implemented on Suidae but was limited for Tayassuidae. As a first step, we generated consensus sequences (147 genes) from each species for comparative analyses. Our results show that: i) the repertoire of Ib and Ia genes is present in both Suidae and Tayassuidae in contrast with the previous hypothesis; ii) these genes underwent a series of duplications before these taxa diverged from the common ancestor ~35Ma; iii) all genes have evolved independently from each other after speciation; iv), there are genetic patterns of differentiation for most of the Ia and Ib genes between Eurasian and sub-Saharan Suidae; and v) balancing and purifying selection appear to have maintained the MHC diversity. These findings improve our understanding of the evolutionary history of the MHCs and provide genetic resources to further investigate the immune response of wild populations to diseases, including local adaptation of some taxa to emerging diseases.