The genes of the major histocompatibility complex (MHC) code for proteins involved in antigen recognition and triggering of the adaptive immune response, and are therefore likely to be under selection from parasites. These selection regimes may vary in space and time. Here we report a strong geographical structure in MHC class II B genes of a migrating bird, the great snipe (Gallinago media). Genetic differentiation in the MHC between two ecologically distinct distributional regions (Scandinavian mountain populations vs. East European lowland populations) was still present after statistically controlling for the effect of selectively neutral variation (microsatellites) using partial Mantel tests. This suggests a role for selection in generating this spatial structure and that it represents local adaptation to different environments. Differentiation between populations within the two regions was negligible. Overall, we found a high number of MHC alleles (50, from 175 individuals). This, together with a tendency for a higher rate of nonsynonymous than synonymous substitutions in the peptide binding sites, and high Tajima's D in certain regions of the gene, suggests a history of balancing selection. MHC variation is often thought to be maintained by some form of balancing selection, but the nature of this selection remains unclear. Our results support the hypothesis that spatial variation in selection regimes contributes to the high polymorphism.