Eating a diet high in processed food increases the risk of depression, research suggests.
What is more, people who ate plenty of vegetables, fruit and fish actually had a lower risk of depression, the University College London team found.
Data on diet among 3,500 middle-aged civil servants was compared with depression five years later, the British Journal of Psychiatry reported.
The team said the study was the first to look at the UK diet and depression.
They split the participants into two types of diet - those who ate a diet largely based on whole foods, which includes lots of fruit, vegetables and fish, and those who ate a mainly processed food diet, such as sweetened desserts, fried food, processed meat, refined grains and high-fat dairy products.
After accounting for factors such as gender, age, education, physical activity, smoking habits and chronic diseases, they found a significant difference in future depression risk with the different diets.
Those who ate the most whole foods had a 26% lower risk of future depression than those who at the least whole foods.
By contrast people with a diet high in processed food had a 58% higher risk of depression than those who ate very few processed foods.
Although the researchers cannot totally rule out the possibility that people with depression may eat a less healthy diet they believe it is unlikely to be the reason for the findings because there was no association with diet and previous diagnosis of depression.
Study author Dr Archana Singh-Manoux pointed out there is a chance the finding could be explained by a lifestyle factor they had not accounted for.
"There was a paper showing a Mediterranean diet was associated with a lower risk of depression but the problem with that is if you live in Britain the likelihood of you eating a Mediterranean diet is not very high.
"So we wanted to look at bit differently at the link between diet and mental health."
It is not yet clear why some foods may protect against or increase the risk of depression but scientists think there may be a link with inflammation as with conditions such as heart disease.
Dr Andrew McCulloch, chief executive of the Mental Health Foundation, said: "This study adds to an existing body of solid research that shows the strong links between what we eat and our mental health.
"Major studies like this are crucial because they hold the key to us better understanding mental illness."
He added people's diets were becoming increasingly unhealthy.
"The UK population is consuming less nutritious, fresh produce and more saturated fats and sugars.
"We are particularly concerned about those who cannot access fresh produce easily or live in areas where there are a high number of fast food restaurants and takeaways."
Margaret Edwards, head of strategy at the mental health charity SANE, said: "Physical and mental health are closely related, so we should not be too surprised by these results, but we hope there will be further research which may help us to understand more fully the relationship between diet and mental health."