The risks increase every time a person suffers an episode of feeling depressed or anxious.
The research was carried out on more than 4,000 adults (3,122 men and 1,241 women) aged 35 to 55 who were followed for more than 19 years.
They were asked questions about their health and had their weight measured at several points over the study period.
The results showed those who suffered anxiety or depression for most of the study were twice as likely to be obese as those who did not have such problems.
The authors, from University College London and the universities of Bristol, Glasgow and Edinburgh, said several factors may explain the results, including the link between mental health problems and eating disorders.
Both over-consumption and under-consumption of food can have an effect on the future likelihood of gaining weight, they said. In addition, people with mental health problems may be less likely to take exercise which can lead to them gaining weight, while some anti-depressants may result in weight gain.
Hormonal imbalance could be another factor leading to people putting on weight, they said.
The research was published online in the British Medical Journal (BMJ).





