When you are struggling with your mental health, getting active may be one of the last things you feel like doing. But if you can muster the energy, evidence shows that exercise has a powerfully beneficial effect. One 2019 study, published in JAMA Psychiatry, found that physical activity is an effective prevention strategy for depression. Another 2015 paper found that exercise can be as helpful in treating mild to moderate depression as antidepressants and psychotherapy.

“We have known for a long time that exercise promotes physiological and neurochemical responses that make you feel good,” says Prof Nanette Mutrie of the University of Edinburgh’s Institute for Sport, Physical Education and Health Sciences. When we exercise, the brain releases endorphins, as well as dopamine and serotonin. “Very often, these same chemicals form part of antidepressant drugs,” she says.

There is also a psychological component to exercise that makes us feel good, says Mutrie. “When you’re exercising, you are improving your self-esteem, mastering a new task and meeting new people. All of this forms part of the mix. There’s this synergy of positive things that is happening.”

If you are struggling with your mental health and are anxious about exercise, the best advice is to start small. “Your goals should be really achievable,” advises Sarah Overall, a London-based personal trainer who is qualified to take referrals from the NHS. “Take it slowly and be proud of every step you take.” She also says you will have setbacks along the way and shouldn’t feel discouraged. “Fitness isn’t linear,” she says. “You can go for a run one day and feel OK, and the next time feel rubbish.” She suggests exercising with a trusted friend, so that you have someone to check in with if you are feeling anxious.

Mutrie suggests a simple walking programme. “Aim to increase the amount you are walking over the course of a month. Start with walking for 10 minutes a day and gradually up it.” Most smartphones now have pedometers, so you can track your steps: 7,000 steps a day is a good target to set yourself, with the aim of eventually increasing it to the government recommendation of 10,000 steps daily.

Running can be a great way of improving your self-esteem – but take it slowly at first. Photograph: Mike Harrington/Getty Images

Jermaine Johnson, another personal trainer who often trains clients with depression and anxiety, suggests avoiding cardio. “That can raise the heart rate and fuel your anxiety,” he says. Instead, he suggests that you try strength training. “I’ve trained people with depression who’ve said weightlifting made a big difference.” Because you can measure your progress with weight training – heavier weights or more repetitions – you will be able to see how much you are improving, which could lift your mood.

You don’t have to exercise all the time. “If you want to optimise your exercise regime for your mental health, according to our research, exercising for 45 minutes at a time, three to five times a week, has the most beneficial mental health effects,” says Dr Adam Chekroud of Yale School of Medicine. He is the co-author of one of the biggest studies into exercise and mental health, which looked at 1.2 million adults in the US. He says that cycling and team sports will give you the biggest boost, but even walking or doing household chores are better than nothing.

It’s a good idea to pick times when gyms are less busy, so you won’t feel like you are being watched. “Speak to the gym manager and ask them about their quiet times and quiet areas,” Overall says. If you’re able to slip away from work, gyms are generally quiet in the mid-afternoon. Plus, you won’t have to drag yourself out of bed at the crack of dawn. “If it’s dark or rainy, it can be hard to get up early, especially if you’re struggling with depression,” she says.

Just being in nature has also been shown to have beneficial mental health effects. “You need sunlight for vitamin D, and vitamin D lifts your mood,” says Overall. Look for a Green Gym near you: these free, conservation-based workouts are a great way to meet people in your local area, if you’re feeling lonely; sign up and you could be planting trees or sowing seeds alongside other participants. Beyond that, the mental health charity Mind has a directory of fitness classes and other outdoor activities on its website (mind.org.uk), many of which are free.

If you feel up to being around other people, group exercise can help. “When it comes to depression or stress, these conditions have a biological underpinning, but they also have social components,” Chekroud says. The sense of community you feel as part of a sports team can have a brightening effect on your mood. “It takes the attention away from the individual person,” says Johnson. And if you end up feeling overwhelmed or anxious in the class, it is fine to leave early. “You always have the option to leave. I’ve had people who’ve walked out of my classes,” he says. “That’s fine.” If you’re feeling very anxious before a class, give the trainer a heads-up that you’re not feeling great, and might slip out early – and pick a spot near the door for minimum fuss.

If you pick yoga, start with a beginner’s class rather than anything more intense. Photograph: Thomas Northcut/Getty Images

Johnson recommends starting with a yoga or a barre class, rather than a circuits class, as often these involve partner-work, which can be difficult for those with social anxiety. Whatever you are doing, pick a beginner’s class: now is not the time to throw yourself into Bikram yoga. “If a class is too intense, you’re going to feel like you’re doing badly, and you may end up feeling worse than you did when you arrived,” Johnson says. “That is definitely not the goal.”

Anyone struggling with body dysmorphia “should avoid gyms, as they are full of mirrors”, says Overall. “Instead, take things outside if you can.” Try jogging or doing a high-intensity interval training workout in the park. If you are in recovery from an eating disorder, Overall recommends creating an exercise plan under the supervision of a mental health professional, to avoid overdoing it. “Otherwise, it’s like an alcoholic going back in a pub. It’s got to be carefully managed.”

If you don’t feel as if you can leave your house, there are plenty of fitness videos online that you can do at home. Try Fitness Blender, or download the Nike app. If you can afford a personal trainer, look for one who has an exercise referral qualification, meaning they are accredited to work with the NHS. Explain your mental health challenges to them and have them tailor an appropriate programme; speak to your doctor to ensure your workout is medically safe.

When you are exercising, it is absolutely fine to take a break, or stop entirely, if you are feeling overwhelmed. “Don’t feel like you have failed because you had to stop,” says Overall. When you are struggling with your mental health, it is easy to get trapped in a spiral of negative thoughts and think that everyone in your gym is watching you. But they are almost certainly not, says Johnson. “Ninety per cent of the time, people aren’t thinking about you – they’re focusing on their own workout.”

Finally, the act of putting on a pair of trainers can, on its own, be a form of self-care. “Even if you leave after a few minutes, you’ve already achieved something just by going to the gym,” says Johnson. Focus on the fact that you went to the gym in the first place, not that you left. And take everything one step at a time. You’re in control.