Diabetes mellitus and depressive disorders are both common chronic diseases that increase functional disability and social burden. Cognitive impairment is a potentially debilitating feature of depression. Previous evidence has revealed that the antidiabetic drug metformin could be suitable for diabetic patients with cognitive impairment. However, there is no direct evidence from clinical studies that metformin treatment improves cognitive function in diabetic patients suffering from depression. In this study 58 participants, diagnosed with depression and type 2 diabetes mellitus, were recruited and divided into two groups: one treated with metformin and one with placebo for 24 weeks. Cognitive function, depressive behavior and diabetes improvement were evaluated. Chronic treatment with metformin for 24 weeks improved cognitive performance assessed by the Wechsler Memory Scale‐Revised (WMS‐R) in depressed patients with type 2 diabetes mellitus. In addition, metformin significantly improved depressive performance and changed the glucose metabolism in depressed patients with diabetes. Depressive symptoms negatively correlated with the cognitive performance in metformin‐treated participants. Furthermore, associations were also observed between the parameters of blood glucose metabolism and the depression phenotype. These findings suggested that chronic treatment with metformin produced antidepressant behavioral effects, and that improved cognitive function is involved in the therapeutic outcome of metformin. The current results also raised the possibility that supplementary administration of antidiabetic medications might enhance the recovery of depression, co‐morbid with type 2 diabetes mellitus, through improvements in cognitive performance. This article is protected by copyright. All rights reserved.