Have you been fired? Lost out on a big project or a big sale? Started a company that failed? Chances are some friend or family member told you at the time that this painful setback would lead to greater success later on. Now there’s scientific evidence to suggest whoever said that is right. 

In a fascinating study published this month in Nature, a team of scientists from Northwestern University led by Yang Wang reviewed applicants for National Institutes of Health (NIH) grants. The researchers compared scientists who just barely missed out on getting grants to “statistically identical” scientists who just barely succeeded in getting grants. The called the first group “narrow wins” and the second group “near misses.” They then followed the careers of each for 10 years.

The researchers guessed that the disappointment of not getting the grant might be enough to drive some scientists to pursue different career paths or specialties, and they were right. A near miss equated to “more than a 10 percent chance of disappearing permanently from the NIH system,” they wrote. But those who didn’t disappear went on to have better, more high-achieving careers than their counterparts who got grants.

This didn’t happen right away. During the first five years after missing out on an NIH grant, the scientists that narrowly obtained the initial NIH grants went on to receive more grants from the NIH and also from the National Science Foundation than those who didn’t obtain that initial funding. But after five years, the difference disappeared, with each group receiving similar amounts of grant money. And after 10 years, the researchers found that those who just missed getting that early grant “ultimately published as many papers and, most surprisingly, produced work that garnered substantially higher impacts than their narrow-win counterparts.” They noted, “Despite an early setback, individuals with near misses systematically outperform those with narrow wins in the longer run.” 

Failure really is good for you.

The researchers wondered whether they were observing a cause or an effect–that is, did the early setback serve to winnow out weaker candidates, leaving only the strong behind, or did failure itself help people become more successful later on? To answer that question, they artificially performed a similar winnowing on those who did get grants, removing the weakest performers from the sample. Even so, those who’d had that early career setback significantly outperformed their peers who hadn’t. It was the failure itself–the knowledge and resiliency gained by going through it and emerging whole–that gave those scientists more successful careers over the long term.

These results lend credibility to the old saying that “what doesn’t kill us makes us stronger,” as well as to venture capital firms’ willingness to give a founder whose first company failed a second chance with a new startup. But there’s an even more important lesson here for anyone who’s ever had a big setback: Just because you failed doesn’t mean you’ll fail next time if you try again. In fact, it raises your odds of ultimate success.

Try to remember that the next time you find yourself reeling from a big career disappointment. It may feel awful in the short term. But in the long term you’re likely to reach greater heights than you would have if it had never happened. That setback may mean you’ll be much more successful in years to come.