Diabetes severely impairs male reproduction. The present study assessed the effects and mechanisms of action of advanced glycation end products (AGEs), which play an important role in the development of diabetes complications, on testosterone secretion by rat Leydig cells. Primary rat Leydig cells were cultured and treated with AGEs (25, 50, 100 and 200 µg/ml). Testosterone production induced by human chorionic gonadotropin (hCG) was determined by ELISA. The mRNA and protein expression levels of steroidogenic acute regulatory protein (StAR), cholesterol side-chain cleavage enzyme (P450scc) and 3β-hydroxysteroid dehydrogenase (3β-HSD), which are involved in testosterone biosynthesis, were measured by reverse transcription-quantitative PCR and western blot analyssi, respectively. Reactive oxygen species (ROS) production in Leydig cells was measured using the dichlorofluorescein diacetate (DCFH-DA) probe. The expression levels of endoplasmic reticulum stress-related proteins [C/EBP homologous protein (CHOP) and glucose-regulated protein 78 (GRP78)] in the Leydig cells were measured by western blot analysis. We found that the AGEs markedly suppressed testosterone production by rat Leydig cells which was induced by hCG in a concentration-dependent manner compared with the control (P<0.01). The mRNA and protein expression levels of StAR, 3β-HSD and P450scc were downregulated by the AGEs in a dose-dependent manner compared with the control (P<0.01). The antioxidant agent, N-acetyl‑L‑cysteine (NAC), and the endoplasmic reticulum stress inhibitor, tauroursodeoxycholic acid (TUDCA), reversed the inhibitory effects of AGEs. In addition, the content of ROS in Leydig cells treated with AGEs increased significantly. The expression levels of CHOP and GRP78 were markedly upregulated by the AGEs in the Leydig cells. From these findings, it can be concluded that AGEs inhibit testosterone production by rat Leydig cells by inducing oxidative stress and endoplasmic reticulum stress.