After a sterling performance in 2016, Barrick (ABX) had a rocky 2017 as it hit some stumbling blocks. Investors overreacted, and the shares were hurt, suggests Stephen Leeb, editor of Real World Investing.

But the problems it faced this year in no way should affect the company over the longer term, and while some downside risk may remain, Barrick is a compelling buy with upside potential that is many times the risk.

Barrick not only is the world’s biggest miner, by most metrics it also currently is the cheapest. Indeed, the stock today is cheaper than when it traded at all-time highs in the mid-$50s at the decade’s start. If gold prices simply remain where they are, we think Barrick’s potential is several times its current price.

But we don’t expect gold prices to remain static. Rather, I think that gold will enter a powerful bull market. And if gold vaults into high gear, the potential gains for Barrick are truly enormous.

One of the recent setbacks related to an ongoing tax and profit-sharing spat with the Tanzanian government. Barrick’s management expects the dispute will be settled in 2018’s first half, which seems like a reasonable timeline.

Even on a worst-case basis, though, the Tanzania operation represents only around 6 percent of Barrick’s revenues, not enough to dent the exceptional long-term potential. Indeed, the drop in Acacia already has been reflected in a substantial out-of-proportion 26 percent decline in Barrick.

Since 2013 debt has fallen by more than 50 percent and is now $6.4 billion. Further reductions in debt to the $3 billion-$4 billion range are within easy reach with the potential sale of noncore assets.

The most striking number is that free cash flow today — even despite all the 2017 problems — is twice as high as in 2011, when the stock peaked at over $50. Moreover, debt in 2011 was more than twice as high as debt today.

We expect free cash flow to climb steadily for the foreseeable future. Over the next two to three years, most of the gains will come from a wider use of the company’s advanced technologies, which have been successfully tested for gold and other metal production.

Looking further ahead, Barrick has stakes in a number of projects that are in development and that eventually could radically increase production.

In sum, while Barrick still faces a bit of uncertainty, the longer-term trajectory of costs, production, and balance sheet improvement points to a target of $50 to $60 assuming gold merely treads water. And if we’re right about a major bull market in gold, Barrick shares have the potential to climb well into three digits.

Subscribe to Real World Investing here…