The HLA-B27 gene is a major risk factor for clinical diseases including ankylosing spondylitis, acute anterior uveitis, reactive arthritis, and psoriatic arthritis, but its mechanism of risk enhancement is not completely understood. The gut microbiome has recently been shown to influence several HLA-linked diseases. However, the role of HLA-B27 in shaping the gut microbiome has not been previously investigated. In this study, we characterize the differences in the gut microbiota mediated by the presence of the HLA-B27 gene. We identified differences in the cecal microbiota of Lewis rats transgenic for HLA-B27 and human β2-microglobulin (hβ2m), compared with wild-type Lewis rats, using biome representational in situ karyotyping (BRISK) and 16S rRNA gene sequencing. 16S sequencing revealed significant differences between transgenic animals and wild type animals by principal coordinates analysis. Further analysis of the data set revealed an increase in Prevotella spp. and a decrease in Rikenellaceae relative abundance in the transgenic animals compared to the wild type animals. By BRISK analysis, species-specific differences included an increase in Bacteroides vulgatus abundance in HLA-B27/hβ2m and hβ2m compared to wild type rats. The finding that HLA-B27 is associated with altered cecal microbiota has not been shown before and can potentially provide a better understanding of the clinical diseases associated with this gene.