Adults who have either depression or type 2 diabetes may have an increased risk of developing dementia, and the risk may be even higher for people who have both conditions, according to a new study. 

In the study, researchers examined the risk of dementia in more than 2.4 million people in Denmark ages 50 and older, a group that included people who had type 2 diabetes, depression or both conditions. About 2 percent of the people in the study developed dementia over the six-year study period.

But among those who developed dementia, more than 26 percent had depression, and almost 11 percent had type 2 diabetes. In addition to those groups, another 7 percent had both conditions.

The researchers found that the people with diabetes had a 20 percent greater risk of dementia compared with the people who did not have diabetes or depression. For the people who had depression, the risk of dementia was increased by 80 percent.

The researchers were surprised that the risk of dementia for the people with depression but not diabetes was so much higher than for those who had diabetes but not depression, said study author Dr. Dimitry Davydow, of the University of Washington School of Medicine in Seattle.

"Essentially, what we found is that the risk associated with depression was four times greater than that associated with diabetes," Davydow told Live Science. [7 Ways Depression Differs in Men and Women]

The people who had been diagnosed with both diabetes and depression were more than twice as likely to have dementia during the study period than people who did not have either condition. (In people with type 2 diabetes — which is the most common type of diabetes, making up about 90 percent of cases — the cells of the body can no longer respond to the hormone insulin by taking in sugar from the bloodstream.)

The investigators also found that the risk of dementia related to having both diabetes and depression was greater among people younger than 65. For people in this age group, the combination of diabetes and depression explained about 25 percent of the cases of dementia. In comparison, in the overall population of the study (all age groups), about 6 percent of the dementia cases were explained by having both conditions, Davydow said.

The authors of the new study did not examine the potential mechanisms that could explain the relationship between diabetes and/or depression and type 2 diabetes. However, Davydow said it's possible that diabetes affects the blood supply to the brain and may contribute to dementia.

The link between depression and dementia may be related to the increased inflammation that tends to accompany depression, as this inflammation may also lead to dementia, he said.

The rates of both dementia and type 2 diabetes are increasing in the United States, Davydow said. Eating a healthy diet and exercising can help prevent type 2 diabetes.

"If we don't do something about this, we could have an even greater epidemic of cases of dementia developing at even younger ages than what we are seeing now," Davydow said.

The new study was published today (April 15) in the journal JAMA Psychiatry.

Copyright 2015 LiveScience, a Purch company. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.