Woman A is having a bad day. First, her boss comes by and barks at her for missing a deadline. Then her mom calls and guilt-trips her for forgetting her aunt's birthday. Oh, and that new guy she has been texting? He's MIA.

Her stress hormones—cortisol and adrenaline—are surging. In her brain, cortisol is binding with receptors in the hippocampus, the seat of memory formation and learning. For now, this will hone her recall. But if she doesn't get her stress in check, over time, key connections between nerve cells in her brain won't function as well, impairing her memory and her ability to take in new information, and raising her risk for depression and anxiety.

All she knows is that she's overwhelmed. So at lunch, she heads to the gym and hops onto the elliptical. As her heart begins to pound, levels of the feel-good neurochemicals serotonin, dopamine and norepinephrine rise in her body. So does brain-derived neurotrophic factor (BDNF), a substance that may protect her brain from emotional disorders and repair damage that stress and depression cause. At the same time, opiate-like endorphins and endocannabinoids (similar to the other kind of cannabis) flood her system, leading to a sense of well-being.

People often throw around terms like "endorphin rush" or "runner's high" to explain the mood lift that can occur during or after a sweat session. But rather than a sudden burst of euphoria, research has found that a mere 20-minute workout can produce more subtle mood benefits that last as long as 12 hours. And when it comes to shorter bouts of activity, endorphins may actually have little to do with the mental perk-up.

 Woman A is feeling so good that she cranks up the elliptical. As she does, her body begins releasing gamma-aminobutyric acid, or GABA, a calming neurotransmitter. Not that she is calm, exactly; she's subjecting her system to a low-level form of stress. "Exercise raises your heart rate and triggers a surge of hormonal changes. Expose yourself to this 'stress' enough and your body builds up immunity to it. Eventually, it will get better at handling the rest of life's stressors," says clinical psychologist Jasper Smits, Ph.D., coauthor of Exercise for Mood and Anxiety. But stay sedentary and your body can become more sensitive to stress, so even minor triggers leave you tied up in knots.