Berberine (BBR) is used to treat diarrhea clinically. However, its reproductive toxicity is unclear. This study aims to investigate the impact of BBR on the male reproductive system. Intragastric BBR administration for 14 consecutive days results in a significant decrease in the serum testosterone concentration, epididymal sperm concentration, mating rate and fecundity of male mice. Testicular treatment with testosterone propionate (TP) partially reverses the damage caused by BBR to the male reproductive system. Mechanistically, the decrease in Muribaculaceae abundance in the gut microbiota of mice is the principal cause of the BBR-induced decrease in the sperm concentration. Both fecal microbiota transplantation (FMT) and polyethylene glycol (PEG) treatment demonstrate that Muribaculaceae is necessary for spermatogenesis. The intragastric administration of Muribaculaceae intestinale to BBR-treated mice restores the sperm concentration and testosterone levels. Metabolomic analysis reveals that BBR affects arginine and proline metabolism, of which ornithine level is downregulated. Combined analysis via 16S rRNA metagenomics sequencing and metabolomics shows that Muribaculaceae regulates ornithine level. The transcriptomic results of the testes indicate that the expressions of genes related to the low-density lipoprotein receptor (LDLR)-mediated testosterone synthesis pathway decrease after BBR administration. The transcriptional activity of the Ldlr gene in TM3 cells is increased with increased ornithine supplementation in the culture media, leading to increased testosterone synthesis. Overall, this study reveals an association between a BBR-induced decrease in Muribaculaceae abundance and defective spermatogenesis, providing a prospective therapeutic approach for addressing infertility-related decreases in serum testosterone triggered by changes in the gut microbiota composition.