Being too thin in middle age might be bad for brain health later in life, a new study suggests.

Researchers found that people who were underweight in their 40s, 50s and 60s were 34 percent more likely to be diagnosed with dementia up to 15 years later, compared with similarly aged men and women who were a healthy weight.

Exactly why being underweight —defined as having a body mass index (BMI) of less than 20 —in middle age is linked with dementia is unclear and requires further investigation, said study co-author Dr. Nawab Qizilbash, a clinical epidemiologist and the head of OXON Epidemiology, a research organization in London. But he speculates thatfactors such asdiet, exercise, frailty, weight changesand deficiencies in vitamins D and Emight play a role.

The study, published online April 10 in the journal The Lancet Diabetes & Endocrinology, analyzed data from nearly 2 million people ages 40 and older in the United Kingdom. [8 Tips for Healthy Aging]

None of the people had dementia when the study began, but nearly 46,000 were diagnosed with it during the follow-up period of up to 20 years.

In a surprising finding that contradicts some previous studies, the researchers found that being overweight or obese in middle age actually appeared to protect brain health.

In fact, people who were the heaviest at midlife, with a BMI of 40 or higher, had a 29 percent lower risk of developing dementia than people whose weight fell into a healthy range, according to the study.

"Contrary to the prevailing — but not unanimous — view, people who are overweight or obese in middle age appear not to be at higher risk of dementia in old age," Qizilbashtold Live Science.

He said these findings were unexpected, and although the research team performed many different analyses to see if they could find an explanation for the results, so far they have not.

Qizilbash said some next steps in this research include understanding the influence of weight changes, such as recent weight loss in a person who may not have previously been underweight, on the risk of dementia.

He also wants to look into whether being overweight or obese hasan overall positive effect on dementia because someone who weighs more may not live long enough to reap its possible brain-protective effects.

More research is also needed to determine how weight influences the risk of different types of dementia, such as Alzheimer's disease, vascular disease and Lewy body disease, Qizilbash said.

Follow Live Science @livescience, Facebook & Google+. Original article on Live Science.