For the most part, every runner has experienced a freak-out moment mid-race. Dr. Rick Hecht’s was on the climb to Michigan Bluff around the halfway point of the Western States 100-Mile Endurance Run. Considered to be one of the toughest footraces in the world, with more than 50 rugged miles complete, his body began to turn on him. The muscles in his legs burned intensely with every step and his stomach churned as nausea set in.

A professor of medicine at the University of California, San Francisco, and a seasoned ultrarunner, he recalled the scene, saying, “I felt terrible and I thought, ‘Oh my gosh, I’m never going to be able to go on.’”

Fortunately, Hecht’s professional expertise kicked into gear. Also the research director at the Osher Center for Integrative Medicine at UCSF, he’s conducted countless studies on mind-body interventions in the medical field and authored hundreds of peer-reviewed articles. Instead of resisting or fighting the physical suffering in the moment, Hecht, a long-time subscriber to mindfulness meditation, tapped into his practice to examine the sensations.

“Being able to work with those feelings was still tough,” he says. “But mindfulness gave me the sense that I could think my way through them.”

While you may not have tapped the 100-mile distance as of yet, all runners experience moments of extreme discomfort in both workouts and races. Even easy running can feel like a sufferfest when we are out of shape. When I was coming back to running after having my first baby, I couldn’t believe how challenging just a few miles often felt—the niggles and tweaks that plagued me and the ever-present burn in my lungs. Despite having done an Ironman right before I got pregnant and jogging through 40 weeks, the changes that my body had undergone, paired with time off during my daughter’s first weeks in the world, left me wholly out of shape.

Similar to Hecht, I discovered that when I was able to steer my attention toward the discomfort, rather than launching an internal debate about why the heck I was out running in the first place, the suffering dissipated. Mindful awareness allowed me to gain some perspective so I could see the discomfort for what it was: Part of the process of getting back to fitness.

In the simplest terms, mindfulness is about bringing non-judgmental awareness to the present moment. Every time your mind wanders to ruminating about the past or worrying about the future, mindfulness calls you to take notice and gently redirect to the present. It’s all about course correcting.

For instance, when it comes to the discomfort of navigating a formidable climb in the final mile of a long run, you might notice your burning quads and screaming lungs. Instead of checking out as soon as things get hairy, examine the physical sensations, perhaps even name them (“burning quads,” “sore calves”), accept their presence, and then redirect to the simple act of putting one foot in front of the other to get up the hill. So often we have an emotional reaction to this kind of discomfort—usually involving anger and anxiety—Why am I doing this? I hate running! I’m so out of shape! Why does this feel so hard?

Pain and discomfort is like a two-headed monster—one head represents the sensory component or the physical sensations and the other represents the emotional component. As research suggests, when we’re running on autopilot, we tend to cycle negative and anxious thoughts that make pain and discomfort more intense. Taking a moment to examine the discomfort while you’re running allows you to bring a more objective mind to the table so you can make intentional decisions about what to do next.

Consider these three specific ways that mindfulness can help runners handle discomfort and pain:

1) It keeps you from catastrophizing pain.

Psychologists often refer to the attempt to suppress thoughts as the “white bear problem.” This comes from Fyodor Dostoevsky’s 1863 pondering where he wrote, “Try to pose for yourself this task: not to think of a polar bear, and you will see that cursed thing will come to mind every minute.” To be sure, trying to check out when discomfort sets in has a paradoxical effect, actually intensifying the sensations.

“In the past, we often talked about ignoring or pushing away discomfort, but mindfulness actually calls you to pay attention to it and notice it in a careful, non-judgmental way,” Hecht told me. “Often someone realizes that it isn’t as bad when you’re not trying to push it away—that they were ruminating or catastrophizing and making the pain worse. You can actually work with the pain in a different way when you’re applying mindfulness instead of getting freaked out.”

Research backs this up, showing that our perception of uncomfortable physical sensations is often malleable depending on how we relate to them. Mindfulness training has been shown to reduce pain in patients in a wide array of clinical settings. As the “Ultramarathon Man” Dean Karnazes told me, “pain is in the neurons of the beholder.”

2) It enhances your belief that you can handle the discomfort.

As Hecht suggested, mindfulness allowed him to think his way through the agony of a monster climb in a 100-mile race. Often referred to as self-efficacy, your belief that you are capable of navigating a particular challenge can go a long way towards getting you to the other side.

As you might guess, research on mindfulness in the medical field shows that it can help a person build that sense that they will be up to the challenge and able to deal with pain and discomfort in a constructive manner. When we lack that self-belief, our defense mechanism is generally to hide from or resist it, which ironically, only makes it worse.

3) It trains you to listen to your body.

While the majority of the discomfort we experience on the run is due to the nature of hard physical efforts, on occasion, it can signal an injury. As luck would have it, mindfulness can serve you in this instance too by training you to better listen to your body.

“Mindfulness can help you discriminate the difference between the discomfort associated with a hard effort in training or racing and one that is going to lead to injury,” Hecht said. “From my personal experience, it helps me pay attention to my body’s cues and signals when I’m running.”

While practicing mindfulness will help build a natural sense of body awareness to clue you in when something is going haywire, here are a few questions to ask yourself as you examine pain or discomfort on the run:

– Have I felt this pain before?

– Could this be related to a past injury?

– Is it a shooting, sharp pain or a dull ache?

Research demonstrates that practicing mindfulness can boost body awareness, thereby helping you build a sense for what is and isn’t typical for your body, so you can discern when to push through discomfort and when to back off.

You’ll often hear coaches preach to their athletes to “control the controllables.” While you can’t eliminate the discomfort that accompanies running, you can change your relationship to it. By tuning into those sensations, you create a little breathing room and reduce their power. This can be the difference-maker when it comes to those decisive moments where freaking out or settling in and pushing forward are your main moves.