After four years of pushing the proverbial rock—or in his case, frozen burrito—up the entrepreneurial hill, Mike Adair could finally see progress. Sales for his Red’s All Natural burritos had grown to the point that he needed a big manufacturing partner to scale up production. A months-long search led to a new factory—and then a blindside tackle by Murphy’s Law.

“We realized that they had overpromised and didn’t have the ability to do a fraction of what we needed,” says Adair, who launched his company, which is based in Franklin, Tenn., on a hunch that the world needed an all-natural burrito, just like the ones his wife made. “They were shorting at least half our orders, and our retailers were threatening to throw us out. We were almost out of money. It was a pretty dark time. I wasn’t sleeping. I think I aged 10 years in those four or five months.”

Adair had an inkling of what he was in for when an entrepreneurship professor called his burrito concept the worst idea he’d ever heard. Adair had left a job as a mutual-fund sales director making $350,000 a year for no salary and the prospect of duking it out with sleazy manufacturers and malfunctioning burrito-wrapping machines. It stretched him to the limit. How was he going to get out of this one?

He managed by employing the entrepreneur’s secret weapon: willpower, the ability to exercise self-control, to refrain from panicking and to withstand the challenges that come with risk-taking.

“The thought that kept me going was that I have a wife, three little kids, employees and investors, so giving up was never an option. If you hold on to that mentality, you will be amazed at what you can accomplish,” says Adair, whose products are now sold in 10,000 stores across all 50 states. “A little small-batch gin helps, as well.”

Most humans don’t willingly take on adversity. We have an ingrained preference for the easy road, known as the law of least effort. Nobel Prize-winning researcher Daniel Kahneman has detailed a host of ways our brains are primed to opt for the easier, quicker or more impulsive route.

But starting a business blows up that habit. The entrepreneur chooses to engage in difficult tasks, facing formidable obstacles without letup for a very long time. That requires an antidote to the “easy” reflex—and that antidote is willpower.

Filling up the tank

Willpower is the engine of self-control, the ability to manage thoughts, emotions and harmful habits and override momentary desires for the sake of long-term benefits. It’s crucial for determination, tenacity and achieving goals. Entrepreneurs must be well-stocked with willpower to prevail over the difficulties that swarm like mad hornets when one embarks on a self-made path.

Steely will is usually associated with business moguls or superhero athletes, but the ability is not innate. It’s something we can all build like muscle, say researchers who study the realm of self-regulation. Willpower is the result of how good we are at self-regulating—controlling impulsivity, holding off indulgence and persevering for a reward that may be far down the line.

In a world of instant gratification, delaying payoff isn’t a popular choice—not surprising, because self-regulation is hard. It’s hard for brain neurons to resist an easier path. A 2000 study found that mental resources are depleted by self- regulating processes such as resisting temptation, restraining aggression and coping with fear. The research suggested that self-control is a limited resource that must be resupplied regularly; each act of self-regulation makes it harder to perform another, because it burns up precious mental resources needed for discipline.

But more recent data indicates that willpower is not so limited after all. You have enough to meet any challenge—if you believe you do. It’s all about mindset.

“We don’t say it’s unlimited. At some point you do need to replenish,” says Carol Dweck, a Stanford University psychology professor and a leading motivation researcher. But willpower, she says, “is a much larger resource than previously thought. You can get tired, but it doesn’t mean you’re out of gas.”

Dweck and her colleagues have found that people who believe their willpower is limited feel tapped out after a strenuous mental task, while those who believe they have abundant willpower are able to push on. “Those with an abundant view aren’t monitoring themselves. They’re just kind of carrying on,” she says.

And once you resist temptation, it’s easier to resist it in the future. You can build willpower over time, in other words, by using it—something you can do by deploying the right motivation and belief systems, priming persistence and sidelining the quick-fix ego.

Mind over matter

Achievement takes effort, and effort requires command of a brain function known as “effortful control.” Part of the executive attention function system, a disciplined effortful control mechanism is essential to self-control and the ability to resist temptation. It regulates impulse control, which prevents you from checking email when you’re trying to complete a task, or helps you delay gratification so your sweat equity can pay off later.

Kahneman notes that people who are simultaneously challenged by a demanding cognitive task and a temptation are more likely to yield to the temptation. Similarly, people who are “cognitively busy” are more likely to make selfish choices. (He points out that a few drinks have the same effect, as does a sleepless night—the self-control of “morning people” is impaired at night, and vice versa.)

Other researchers have found that self-regulation depletes energy in the brain in the form of blood glucose. Subjects given sugary drinks were able to replenish resources to take on hard tasks that demanded self-control. Yet as Dweck (and many entrepreneurs) discovered, there is another energy source: one’s own belief system and the motivation that drives it. Priming yourself with a realistic expectation of a rough road and the belief that you are up to it can get you through.

Hayden Williams and Paul Osetinsky, who started Treatings, a professional networking app, are up to their necks in delayed gratification. They quit well-paying jobs in finance three years ago and have been slogging in the trenches of startup mode since. Their sacrifices have included using a New York University library as an office and sharing a bunk bed to cut down on apartment expenses.

“Looking at it, it’s not sustainable, but I have the perspective of knowing what I don’t love,” Williams says. “The money can’t buy me happiness.”

Not wanting to go back to the financial world, Williams and Osetinsky prepared themselves for a long haul, not a quick fix. So they have been able to stay motivated while writing code and testing their concept, and not fall prey to the nagging of ego and external motivation—i.e., payoff, now.

Instead, their focus is on fine-tuning the technology, learning their customers’ needs and believing that their product can provide a valuable service by introducing people to professionals outside their fields. Williams is fueled by the stories of people using his product in its test phase in New York: One customer, he says, got a job with Deutsche Bank; another found an investor.

The desperation of having one’s butt on the line can be potent fuel for willpower. When motivation is driven by intrinsic goals that align with one’s inner goals—learning, challenge or the thought of making a difference—one has more staying power. When motivation is external—money, fame, praise, status—and the entrepreneur has to endure a long time without, it’s harder to stick with it.

Williams opted for the resilient, intrinsic course. “Our goal is to help people, to help them create new professional relationships,” he says.

In one study, Stanford’s Dweck found that college students who were concerned about grades and self-validation (external performance goals) weren’t as interested in tackling difficult goals with the possibility of failure, showing “substantial decreases in intrinsic motivation” after a significant setback. On the other hand, students who were in it for the learning—who want to work harder to increase their understanding—persevered.

Perry Tam had a major learning experience after starting a business in 2009 making iOS video games in his living room. The first game he and his co-founders built was a bust. “It was not successful at all,” he says. “It was very simple and not good-looking.” Tam knew he and his partners could do better. Their second game improved on the first, and by the fourth, their company, Storm8, was on its way. Today Tam is CEO of a bustling Bay Area venture with 45 games in its repertoire that he says rack up 50 million gamers a month.

Tam and his associates were smart enough to see the first attempt as a learning experience. Long-term and not ego-dependent, such intrinsic goals place the emphasis on process, not immediate payoff.

Let go of ego

The startup annals are filled with cases of people whose products were considered a joke (King Gillette, inventor of the disposable razor); who were down to their last dime (FedEx founder Frederick Smith, who saved his company by taking his last $5,000 to Las Vegas and turning it into $32,000 at the blackjack table); or who persevered through failure (GoPro founder Nick Woodman). They tapped their willpower to achieve great success. We are equal to the task when we think we are.

There are ways to overcome setbacks and intractable binds, say educators and researchers: Keep your ego out of it, prime your brain for temptations and have strategies to fortify willpower.

Kyle Jensen, a software entrepreneur and director of entrepreneurial programs at Yale University’s School of Management, teaches students to embrace “evidence-based” entrepreneurship. See the venture process as a scientist would see an experiment, he says, “as data, not a personal critique of you as a human. The data are just data. Adversity is just data.”

Keeping ego out of the equation turns down the irrational emotions that can get the better of entrepreneurs marketing their “babies.” Like scientists, who typically have multiple failures that are considered part of the process, entrepreneurs need to stay objective.

Researchers have found that rehearsing in one’s head the reaction to setbacks can help subjects resist temptation and overcome anxiety. Instead of reacting with autopilot panic and stress when the going gets tough, you can teach the brain to have a different reaction.

One effective tool for this is known as the implementation intention. You create an “if-then” statement that seeds a behavior you want to have in the future—for instance, “If I see chocolate cake, then I’m going to avoid it.” Repeat this phrase a few times, and the next time you see that cake, your brain remembers, “I’ve got to avoid this.”

You can do the same with recurring stressful events or people. “If cash flow tightens, then I won’t panic over projected thoughts about the future but stay focused on the present and sources to increase funds.” Or, “If I am working on a project, then I will not answer email.”

Positive emotions—compassion, gratitude—have also been shown to expand focus and decrease fear. The reduction of fear is important to building willpower, since it cuts stress and the flight reflex to throw in the towel, as well as the chances of making poor decisions based on irrational emotions.

The University of North Carolina’s Barbara Fredrickson, one of the leading researchers on positive emotions and the author of Positivity, has documented that positive emotions can undo consequences of stress—panicked brain, high blood pressure, pessimistic thinking—that undercut confidence and, thus, the will to persevere. But how do you shift out of the negative and into the positive?

Fredrickson says it can be as easy as taking a moment to think about something you are grateful for. In an optimistic state, your brain is open to new ideas and solutions, not constricted to the fear and rumination of a perceived life-or-death emergency that comes with stress. It’s the state of possibility, an essential fuel for entrepreneurs who need to persevere.

One of the best ways to build optimism is an exercise you can do each night as your head hits the pillow. Think of three things that went well that day, then ask yourself why each occurred. You’ll start recognizing the positive events that previously went unnoticed, and that crowds out the negative. Another tip: Reach out for knowledge and contacts, and connect with entrepreneur forums or networking groups via LinkedIn, Meetup or other resources. The right tips and encouragement can go a long way toward building optimism.

People “who persist have the idea that they can improve their abilities,” Dweck says. It comes down to “recognizing that you have more willpower than you think and finding strategies to put that into practice.”