Background. Male reproductive damage, as a common complication of diabetes mellitus (DM), is getting more attention lately. We aimed to explore the protective effects and mechanism of cornuside (Cor) modulating gut microbiota to alleviate diabetes mellitus- (DM-) induced testicular damage. Methods. KK-Ay mice with reproductive damage were randomly divided into the model and Cor treatment groups, and the C57BL/6J mice were used as the normal group. These mice were orally administered Cor for 8 weeks. Results. Cor administration ameliorated the diabetes-related symptoms of polydipsia and polyphagia and lowered the fasting blood glucose (FBG) level. The results of pathological injury showed that Cor improved testicular lesions (the rupture of seminiferous tubules, degeneration of germ cells, and structural shrinkage and separation from each other) in DM model mice. Cor significantly increased the testis/body weight ratio, testosterone, luteinizing hormone (LH), and follicle-stimulating hormone (FSH) levels in KK-Ay mice. Cor also protected from reproductive damage by inhibiting apoptosis in the testes of KK-Ay mice. Moreover, Cor significantly increased the sperm count and sperm motility. Additionally, 16S rDNA sequencing analysis showed that Cor could notably reverse the changes in the distribution of gut microbiota and decrease the abundance of Weissella confusa (Weissella), Clostridium sp. ND2 (Clostridium sensu stricto 1), uncultured bacterium (Roseburia), Anaerotruncus colihominis DSM 17241 (Anaerotruncus), [Clostridium] leptum (Anaerotruncus), unidentified (Ruminococcus 1), and uncultured bacterium (Bilophila), which may be a potential biomarker for diagnosing the testicular injury caused by DM. Meanwhile, the heat map of phylum level suggested that the testicular injury caused by DM is closely related to gut microbiota. Conclusions. Cor could alleviate DM-induced testicular damage, probably by modulating the gut microbiota.