Ecological speciation has been the subject of intense research in evolutionary biology but the genetic basis of the actual mechanism driving reproductive isolation has rarely been identified. The extreme polymorphism of the major histocompatibility complex (MHC), probably maintained by parasite-mediated selection, has been proposed as a potential driver of population divergence. We performed an integrative field and experimental study using three-spined stickleback river and lake ecotypes. We characterized their parasite load and variation at MHC class II loci. Fish from lakes and rivers harbor contrasting parasite communities and populations possess different MHC allele pools that could be the result of a combined action of genetic drift and parasite-mediated selection. We show that individual MHC class II diversity varies among populations and is lower in river ecotypes. Our results suggest the action of homogenizing selection within habitat type and diverging selection between habitat types. Finally, reproductive isolation was suggested by experimental evidence: in a flow channel design females preferred assortatively the odor of their sympatric male. This demonstrates the role of olfactory cues in maintaining reproductive isolation between diverging fish ecotypes.