When you step out of a yoga class, no doubt you feel better from head to toe. Your muscles feel more relaxed, you may feel stronger, and then there’s the mental clarity only om-ing can bring. But what’s really going on in your brain when you pop in and out of downward-facing dog?

“We know that accumulating evidence shows yoga is good for your body, health and mind. Yoga has been used in the treatment of anxiety conditions, depression, insomnia, eating disorders, and others,” says Jonathan Greenberg, PhD, a postdoctoral research fellow in the department of psychiatry at Massachusetts General Hospital and Harvard Medical School. Even when applied to large populations, like those in prison, it increases inmates’ sense of wellbeing and self-control.

Yoga takes the edge off

With all of those broad benefits, you want to know exactly how a simple sun salutation or tree pose changes your brain. While research is still building, Greenberg notes that one potential reason is yoga’s big impact on dialing down chronic stress. “We know stress is a very fertile ground for many physical and mental ailments,” he says, also pointing out that evidence shows yoga in general can help improve mood and emotional regulation, both of which are associated with reductions in the stress hormone cortisol. Even better: yogis feel this even after a single class.

Take one recent study in the journal Frontiers in Immunology, which found that mind-body exercises like yoga actually decrease the cascade of inflammation that so often sits simmering in the body and wreaking havoc due to chronic stress.

You also may capture that zen vibe because yoga is working on an even higher plane to drive down the stresses of the day, put them in perspective and help you cope better in the future when not-so-great things come your way.

Yoga helps you chill out and stay sharp

The deep breathing and meditation may work on what’s called the HPA axis (or hypothalamic-pituitary-adrenal axis), which controls your sympathetic nervous system (the fight or flight response that keeps your body cued up) as well as the parasympathetic nervous system (this tells you to chill out). Yoga may reduce the SNS and increase the PNS, resulting in a reduction in heart rate and blood pressure, says Greenberg. Your brain takes cues from your body (and vice versa, of course), so when your body is calming down, your brain gets the message that all is well.

But you don't want an activated PNS all the time. You’d be a chill zombie. You want to be more like a calm and collected person who’s on the ball. That involves a balance between your SNS and PNS, says Amy Wheeler, PhD, who serves on the board of directors for the International Association of Yoga Therapists and is a professor at California State University in San Bernardino. “What yoga can teach you is to use your SNS when you need it for clarity, alertness and focus without going into the fight or flight response,” she says. “The ultimate goal of yoga is to be calm and alert,” she notes.

Yoga is working on an even higher plane to drive down the stresses of the day, put them in perspective and help you cope better in the future when not-so-great things come your way.

Yoga molds your brain in very good ways as you age

In addition to keeping your body young, yoga turns back the years on your brain, too. In one 2017 study published in the journal International Pschogeriatrics, older adults (over age 55) with mild cognitive impairment spent 12 weeks either practicing Kundalini yoga or memory training. While both groups’ memory improved, the yoga group saw a boost in executive functioning and emotional resilience, possibly due to the chanting in this yoga that strengthens verbal and visual skills, the researchers report.

Additional observational research on mindfulness and meditation (both are large components of yoga) sheds light on how classes may actually influence your brain structure, says Greenberg. (Research on yoga alone is limited, but you can make some inferences by looking at meditation studies, he notes.) Studies looking at how the brain changes before and after meditation found that brain structures involved in awareness, attention and self-related thinking changed in structure and increased in volume, he says. Plus, there’s your memory. “After eight weeks of meditation training, research found that the hippocampus, which is involved in learning and memory, developed more gray matter density,” he notes.

Finally, there’s the fact that yogis tend to have a cooler reaction to problem events — and you’re left wondering how they do it. As Greenberg points out, those who meditate have larger right insula (the portion of the brain that involves body awareness). That’s a good thing. “It’s important when you encounter a stressful situation. Knowing your reaction to stress can help you identify the emotion, nip it in the bud and prevent it from escalating,” he says. Your amygalda — the reptilian part of your brain that reacts to fear —may also decrease in reactivity in response to stress. How’s that for a zen attitude?

How to get the most out of yoga

There isn’t an agreement among researchers that there’s an ideal amount to practice yoga. Forthcoming research that Greenberg is a part of suggests you need 40 minutes a day for significant stress reduction. Of course, a single session can buffer your stress response, but there’s the question about how long that lasts for, and that’s not clear yet.

For her part, Wheeler suggests yoga twice a week. “I’ve been teaching students yoga for 21 years. Every quarter, I see that in just 10 weeks, there’s a noticeable decline in anxiety and stress,” she says. Three times per week is better, but start with the goal of two.

“We can talk about anxiety, depression and blood pressure lowering in yoga, all of those are proven. But the biggest thing we see that results from yoga is that your quality of life will change for the better,” she says.

You heard her. Grab your yoga mat and go!

More "This Is Your Brain On"

Want more tips like these? NBC News BETTER is obsessed with finding easier, healthier and smarter ways to live. Sign up for our newsletter and follow us on Facebook, Twitter and Instagram.