A new study suggests that being overweight at middle age can cut one's risk of developing dementia by 39 percent.

A joint study conducted by researchers at the London School of Hygiene & Tropical Medicine and OXON Epidemiology, both in London, U.K., looked at the medical records of almost two million patients with an average age of 55 for the past 20 years. The average body mass index (BMI) of the participants was 26.5 kg/m2.

The researchers used the Clinical Practice Research Datalink (CPRD), the largest database ever used for a study that associated BMI with dementia risk.

During the nine-year follow-up period, over 45,507 participants, or two percent, were diagnosed with dementia compared to 34 percent of those with a healthy weight. As the participants grew past their middle age, the researchers observed that the risk of developing dementia is also reduced, especially if one is very obese. The results remain the same even after considering other factors such as alcohol use and smoking.

The researchers admitted that further study is needed to rule out the association of weight to dementia. They believe though that their findings are relevant to the development of treatments for the mental condition.

"The reasons why a high BMI might be associated with a reduced risk of dementia aren't clear, and further work is needed to understand why this might be the case," Nawab Qizilbash, study lead author from OXON Epidemiology in London, U.K. and Madrid, Spain, said in a press release. "If increased weight in mid-life is protective against dementia, the reasons for this inverse association are unclear at present."

The researchers know that their findings contradict earlier studies and that it might spark a debate. They also clarified that they are not encouraging people to pile up those extra pounds, especially since obesity is linked to other diseases such as heart disease, stroke, diabetes, and cancers.

"You can't walk away and think it's OK to be overweight or obese. Even if there is a protective effect, you may not live long enough to get the benefits," Qizilbash told BBC News.

The study was published in the April 9 issue of The Lancet Diabetes & Endocrinology.