Animals harbour diverse communities of symbiotic bacteria, which differ dramatically among host individuals. This heterogeneity poses an immunological challenge: distinguishing between mutualistic and pathogenic members of diverse and host‐specific microbial communities. We propose that Major Histocompatibility class II (MHC) genotypes contribute to recognition and regulation of gut microbes, and thus, MHC polymorphism contributes to microbial variation among hosts. Here, we show that MHC IIb polymorphism is associated with among‐individual variation in gut microbiota within a single wild vertebrate population of a small fish, the threespine stickleback. We sampled stickleback from Cedar Lake, on Vancouver Island, and used next‐generation sequencing to genotype the sticklebacks gut microbiota (16S sequencing) and their MHC class IIb exon 2 sequences. The presence of certain MHC motifs was associated with altered relative abundance (increase or decrease) of some microbial Families. The effect sizes are modest and entail a minority of microbial taxa, but these results represent the first indication that MHC genotype may affect gut microbiota composition in natural populations (MHC‐microbe associations have also been found in a few studies of lab mice). Surprisingly, these MHC effects were frequently sex‐dependent. Finally, hosts with more diverse MHC motifs had less diverse gut microbiota. One implication is that MHC might influence the efficacy of therapeutic strategies to treat dysbiosis‐associated disease, including the outcome of microbial transplants between healthy and diseased patients. We also speculate that macroparasite‐driven selection on MHC has the potential to indirectly alter the host gut microbiota, and vice versa.