Emerging evidence has linked the gut microbiota dysbiosis to transplant rejection while memory T-cells pose a threat to long-term transplant survival. However, it's unclear if the gut microbiome alters the formation and function of alloreactive memory T-cells. Here we studied the effects of berberine, a narrow-spectrum antibiotic that is barely absorbed when orally administered, on the gut microbiota, memory T-cells, and allograft survival. In this study, C57BL/6 mice transplanted with islets or a heart from BALB/c mice were treated orally with berberine. Allograft survival was observed, while spleen, and lymph node T-cells from recipient mice were analyzed using a flow cytometer. High-throughput sequencing and qPCR were performed to analyze the gut microbiota. CD8+ T-cells from recipients were cultured with the bacteria to determine potential T-cell memory cross-reactivity to a specific pathogen. We found that berberine suppressed islet allograft rejection, reduced effector CD8+CD44highCD62Llow and central memory CD8+CD44highCD62Lhigh T-cells (TCM), altered the gut microbiota composition and specifically lowered Bacillus cereus abundance. Further, berberine promoted long-term islet allograft survival induced by conventional costimulatory blockade and induced cardiac allograft tolerance as well. Re-colonization of B. cereus upregulated CD8+ TCM cells and reversed long-term islet allograft survival induced by berberine plus the conventional costimulatory blockade. Finally, alloantigen-experienced memory CD8+ T-cells from transplanted recipients rapidly responded to B. cereus in vitro. Thus, berberine prolonged allograft survival by repressing CD8+ TCM through regulating the gut microbiota. We have provided the first evidence that donor-specific memory T-cell generation is linked to a specific microbe and uncovered a novel mechanism underlying the therapeutic effects of berberine. This study may be implicated for suppressing human transplant rejection since berberine is already used in clinic to treat intestinal infections.