The onset of diabetes more than doubles a patient's risk of suffering depression or other mood disorders.
But researchers in Australia and Taiwan also found that metformin, the most commonly used medication for type-2 diabetes, more than halves this risk.
Monash University researcher Mark Wahlqvist, who sifted through 12 years of medical records of adults in Taiwan, said metformin reduced the incidence of dementia and Parkinson's disease as well as mood disorders, especially when used with a sulfonylurea drug to increase the production of insulin.
"Fortunately, we had sufficient patients not on metformin to make the comparison," he said.
"We think the key mechanism relates to mitochondrial function and cellular bioenergetics - metformin would seem to reset impaired energy regulation, perhaps through its action on the enzyme AMP kinase."