Type 2 diabetes mellitus impairs reproductive functions in men, and important tasks are deciphering the mechanisms of testicular dysfunctions in diabetes and the search of effective approaches to their correction. The purpose was to study the effect of four‐week metformin treatment (120 mg kg−1 day−1) of male Wistar rats with high‐fat diet/low‐dose streptozotocin‐induced type 2 diabetes on basal and gonadotropin‐stimulated steroidogenesis, intratesticular content of leptin and the leptin and luteinising hormone receptors and on spermatogenesis. Diabetic rats had hyperleptinaemia, androgen deficiency and reduced sperm count and quality, and in the testes, they had the increased leptin level and the decreased content of the leptin and luteinising hormone receptors and 17‐hydroxyprogesterone. The stimulating effects of chorionic gonadotropin on testosterone production and expression of steroidogenic genes (Star, Cyp11a1) were decreased. Metformin restored basal and gonadotropin‐stimulated blood testosterone levels. In the testes, it restored gonadotropin‐stimulated 17‐hydroxyprogesterone, androstenedione and testosterone levels, Star expression and the content of leptin and the leptin and luteinising hormone receptors. Metformin also improved epididymal sperm count and morphology. We concluded that metformin treatment normalises the testicular steroidogenesis in diabetic rats, which is due to restoration of the gonadotropin and leptin systems in the testes and is associated with an improvement in spermatogenesis.