Saving for retirement, sticking to an exercise routine, quitting smoking…no matter what your goal is, it takes willpower to achieve it. So, how can you strengthen your resolve on those days when your self-control is nowhere in sight?

Turns out that willpower isn’t a character trait or a virtue, as we once thought. Rather, it’s a complex mind-body response that can be strengthened through practice just like a muscle and trained to meet challenges head on, explains Kelly McGonigal, health psychologist and author, of the book “The Willpower Instinct: How Self-Control Works, Why It Matters, and What You Can Do to Get More of It.”

As with any physical effort, flexing your “willpower muscle” may feel uncomfortable at first, but over time becomes less of a struggle. What starts out as a willpower challenge—for instance, choosing a piece of fruit over a pint of Ben & Jerry’s or passing on an expensive pair of shoes—becomes easier the more you do it.

Find out how to strengthen your willpower muscle:

1. Adopt the right mindset
Willpower is all in your head, though not the way we originally thought. Studies have shown that if you believe your willpower is fixed and limited, it’ll be easily depleted. However, if you think of willpower as a reservoir that is self-renewing, something you can strengthen the more you use it, you’ll be able to summon it more easily. For example, if you go to the gym in the morning, you’ll be more motivated to eat a healthy lunch.

2. Minimize distractions
Here’s something most people don’t know: The part of your brain that regulates self-control is also the part you rely on for concentration, decision-making, and long-term planning. Which means that working on a PowerPoint deck, choosing a friend’s wedding gift, and planning dinner or where to go for your next family vacation over the course of a day all drain your willpower batteries.

Willpower is “a level of energy that fluctuates over the day as it is used and replenished,” says Roy Baumeister, PhD, psychology professor and co-author of “Willpower.” Learn to prioritize your time and limit your focus to tasks that need your attention now. Avoid trying to make every decision this instant, which will exhaust you and deplete the mental resources needed to resist temptation.

3. Challenge yourself 
Engaging in exercises that get you out of the habit of doing what comes naturally are like training camp for tougher willpower challenges. Opening the door with your non-dominant hand, sitting up straight instead of slouching, and standing rather than sitting at your computer have all been shown to bolster self-control when practiced over a few weeks.

4. Get enough sleep
Without enough sleep, your brain won’t be able to recruit the systems needed for impulse control. When your brain is sleep-deprived it overreacts to everyday stress and temptations “and loses control over the regions . . . that create cravings,” explains McGonigal. In other words, to function thoughtfully the brain needs to use energy well and sleep deprivation interferes with that. Make sure you’re consistently getting the sleep your body needs by creating—and sticking to—a bedtime routine that supports 7 or 8 hours each night.

Ironically, making these changes may take some . . .willpower. But “there’s a sort of global training effect on that willpower muscle,” says McGonigal. Engaging in any new behaviors that get you out of old habits is like training camp for tougher willpower challenges to come.

Janet Ungless is a New York-based editor, writer, and content strategist with expertise in wellness, health and fitness. She’s written for Prevention, More, Livestrong, and Everyday Health and also worked at exhale mind body spa. Find her on Twitter @jungless