Researchers from the universities of Yale and Oxford have found a moderate level of exercise improves mental health, while excessive workouts can have a negative effect.
Exercising for 30-60 minutes was associated with the biggest reduction in poor mental health days - associated with around 2.1 fewer days of poor mental health.
The study, published in The Lancet Psychiatry Journal, is the largest of its kind to date but it can not confirm that physical activity is the cause of improved mental health.
The scientists, led by experts at Yale University in the U.S. and Oxford University, found that exercising for 45 minutes three to five times a week was associated with the biggest benefits.
Previous research into the effects of exercise on mental health have thrown up mixed results, and some studies suggest that lack of activity could lead to poor mental health as well as being a symptom of it. The benefits of keeping fit and physical exercise have always been proven - exercise reduces the risk of cardiovascular disease, stroke, diabetes, and mortality from all causes, but its association with mental health remains unclear as previous research has produced conflicting results.
Adults taking part in the study said they experienced on average 3.4 days of poor mental health each month. For those who were physically active, this reduced to only two days.
How often and for how long people were active was also important.
Those who did the most exercise - more than five times a week or more than three hours a day - actually had worse mental health than those who did nothing at all. Doing more than this saw the benefits decline.
Dr Adam Chekroud, co-author from Yale University, said: "Exercise is associated with a lower mental health burden across people no matter their age, race, gender, household income and education level". It is based on self-reporting, which is not always accurate, and there is no way of measuring physical activity.
"We are now using this to try and personalise exercise recommendations, and match people with a specific exercise regime that helps improve their mental health".
"However, the nature of the study means it's hard to say more than that with any real certainty", he said.
Prof Stephen Lawrie, head of psychiatry at the University of Edinburgh, said it indicated that social and "mindful" exercise is particularly good for mental health - but not if it is overdone.
Exercising doesn't have to mean pumping iron in the gym or running a marathon.