In vertebrate animals, genes of the major histocompatibility complex (MHC) determine the set of pathogens to which an individual's adaptive immune system can respond. MHC genes are extraordinarily polymorphic, often showing elevated nonsynonymous relative to synonymous sequence variation and sharing presumably ancient polymorphisms between lineages. These patterns likely reflect pathogen‐mediated balancing selection, for example, rare‐allele or heterozygote advantage. Such selection is often reinforced by disassortative mating at MHC. We characterized exon 2 of MHC class II, corresponding to the hypervariable peptide‐binding region, in song sparrows (Melospiza melodia). We compared nonsynonymous to synonymous sequence variation in order to identify positively selected sites; assessed evidence for trans‐species polymorphisms indicating ancient balancing selection; and compared MHC similarity of socially mated pairs to expectations under random mating. Six codons showed elevated ratios of nonsynonymous to synonymous variation, consistent with balancing selection, and we characterized several alleles similar to those occurring in at least four other avian families. Despite this evidence for historical balancing selection, mated pairs were significantly more similar at MHC than were randomly generated pairings. Nonrandom mating at MHC thus appears to partially counteract, not reinforce, pathogen‐mediated balancing selection in this system. We suggest that in systems where individual fitness does not increase monotonically with MHC diversity, assortative mating may help to avoid excessive offspring heterozygosity that could otherwise arise from long‐standing balancing selection.