Understanding genetic diversity in natural populations is a fundamental objective of evolutionary biology. The immune genes of the major histocompatibility complex (MHC) are excellent candidates to study such diversity because they are highly polymorphic in populations. Although balancing selection may be responsible for maintaining diversity at these functionally important loci, temporal variation in selection pressure has rarely been examined. We examine temporal variation in MHC class IIB diversity in nine guppy (Poecilia reticulata) populations over two years. We found that five of the populations changed significantly more at the MHC than at neutral (microsatellite) loci as measured by FST, which suggests that the change at the MHC was due to selection and not neutral processes. Additionally, pairwise population differentiation measures at the MHC were higher in 2007 than in 2006, with the signature of selection changing from homogenizing to diversifying selection or neutral evolution. Interestingly, within the populations the magnitude of the change at the MHC between years was related to the change in the proportion of individuals infected by a common parasite, indicating a link between genetic structure and the parasite. Our data thereby implicate temporal variation in selective pressure as an important mechanism maintaining diversity at the MHC in wild populations.