To explore the impact of history on selection and genetic structure at functional loci, we compared patterns of major histocompatibility complex (MHC) variability in two sympatric species of ctenomyid rodents with different demographic backgrounds. Although Ctenomys talarum has experienced a stable demographic history, Ctenomys australis has undergone a recent demographic expansion. Accordingly, we predicted that MHC allele frequency distributions should be more skewed, differences between coding and noncoding regions should be less pronounced, and evidence of current selection on MHC loci should be reduced in C. australis relative to C. talarum. To test these predictions, we compared variation at the MHC class II DRB and DQA genes with that at multiple neutral markers, including DQA intron 2, the mitochondrial control region, and 8–12 microsatellite loci. These analyses supported the first two of our predictions but indicated that estimates of selection (based on ω-values) were greater for C. australis. Further exploration of these data, however, revealed differences in the time frames over which selection appears to have acted on each species, with evidence of contemporary selection on MHC loci being limited to C. talarum. Collectively, these findings indicate that demographic history can substantially influence genetic structure at functional loci and that the effects of history on selection may be temporally complex and dynamic. © 2010 The Linnean Society of London, Biological Journal of the Linnean Society, 2010, 99, 260–277.