The therapeutic management of Crohn’s disease (CD), a chronic relapsing–remitting inflammatory bowel disease (IBD), is highly challenging. Surgical resection is sometimes a necessary procedure even though it is often associated with postoperative recurrences (PORs). Tofacitinib, an orally active small molecule Janus kinase inhibitor, is an anti-inflammatory drug meant to limit PORs in CD. Whereas bidirectional interactions between the gut microbiota and the relevant IBD drug are crucial, little is known about the impact of tofacitinib on the gut microbiota. The HLA-B27 transgenic rat is a good preclinical model used in IBD research, including for PORs after ileocecal resection (ICR). In the present study, we used shotgun metagenomics to first delineate the baseline composition and determinants of the fecal microbiome of HLA-B27 rats and then to evaluate the distinct impact of either tofacitinib treatment, ileocecal resection or the cumulative effect of both interventions on the gut microbiota in these HLA-B27 rats. The results confirmed that the microbiome of the HLA-B27 rats was fairly different from their wild-type littermates. We demonstrated here that oral treatment with tofacitinib does not affect the gut microbial composition of HLA-B27 rats. Of note, we showed that ICR induced an intense loss of bacterial diversity together with dramatic changes in taxa relative abundances. However, the oral treatment with tofacitinib neither modified the alpha-diversity nor exacerbated significant modifications in bacterial taxa induced by ICR. Collectively, these preclinical data are rather favorable for the use of tofacitinib in combination with ICR to address Crohn’s disease management when considering microbiota.