Gold bars (24-karat) are seen at the U.S. West Point Mint facility in West Point, N.Y., in 2013. (Shannon Stapleton/Reuters)

Stock prices were not the only investment to stage an impressive rally in 2017. Gold, too, found favor, and that’s rare.

The ageless metal has survived for millennia as a seemingly safe harbor for those wary about the future. But at a time when many are bullish about their economic prospects, it climbed just shy of 15 percent for 2017. That came on top of an 8 percent pop in 2016. Gold prices started 2017 around $1,150 per ounce. The metal was trading above $1,300 Tuesday afternoon.

The basket of 30 stocks that make up the Dow Jones industrial average did even better, rocketing 25 percent last year while the Standard & Poor’s 500-stock index grew by 20 percent.

Gold and stocks don’t usually rise at the same time. Gold prices historically retreat when investors feast on stocks. And when stocks are wheezing, gold tends to surge.

So what happened?

Kim Jong Un, for one.

The North Korean leader’s test — after test, after test, after test, after test — of ballistic missiles has put the world on edge; so has President Trump’s threats in response. Gold is one of those places people flee when they worry that things may get messy.

“I would attribute some of the rise in the price of gold to the feeling of uncertainty surrounding that [North Korean-U.S.] dialogue,” said Meghan Milloy, director of Financial Services Policy at the American Action Forum, in an email to The Washington Post.

“You look at those missile launches and see an increase in the price of gold,” said David Meger, director of metals trading for High Ridge Futures in Chicago.

That’s not the whole story. The apprehensions behind the gold surge include an ever-expanding federal debt, inflation fears, a steadily pricier stock market, rioting in Iran and the tinder box that is the rest of the Middle East.

Then there is the state of commodities in general. Commodities are getting more expensive as a world economic boom consumes everything from copper to oil to palladium, the latter used in products as varied as catalytic converters and flutes. Palladium is up 60 percent in the last year.

“Gold is absolutely a safe haven, but it is also a commodity,” Meger said. It benefits from “the same premise that we see in this U.S. and global economic recovery with commodities across the board doing well.”

Meger said he is taking gold orders up and down the investing profile, from institutions to wealthy people to mom-and-pops trying to diversify their nest egg. Aside from geopolitics and the economic tide lifting commodities along with everything else, there is a nagging fear that inflation may be around the corner.

“People buying gold could be looking at this economic growth as potential for inflation creeping into the market in the months ahead,” he said. “Interest rates could be increasing in the months ahead. Gold is an inflation hedge.”

Gold has its naysayers.

“It pays no interest, costs money to store it and has no intrinsic value,” said Daniel P. Wiener, chief executive of Adviser Investments, a Newton, Mass.-based firm that manages more than $5 billion in assets. “If you value those gold bars, you better have insurance on it, too.”

Wiener said people buy gold during tough times because it’s one of the oldest currencies in the world. But he argues it is not a hedge against long-term inflation.

The price of an ounce of gold was at nearly $2,800 in January 1980 on an inflation-adjusted basis, Wiener said. “Today it’s at $1,300-something.”

People have long been comfortable with gold because they can touch it, store it, look at it and make things with it. Unlike real estate, it’s fungible. You can move it from one place to another, even from one country to another, and still sell it at the world rate. That is not always true for other valuables. Try packing your suitcase with oil or paintings, cocoa beans or cattle.

Gold has several properties that make it a valuable commodity. It is relatively rare, does not tarnish and is easily alloyed with other metals. In addition to being soft, it resists corrosion and can be melted down and transported into many forms, which is why it is used most often in jewelry.

There are several ways to invest in the precious metal.

Meger primarily sells gold two ways: physical gold in bars and, secondly, through futures contracts in which the buyer agrees to take ownership of a specified amount of gold some time in the future at a set price.

Investors can also buy gold through exchange-traded funds and through the purchase of stock in companies that mine for gold.

Gold, though, remains a highly volatile investment. The price for an ounce of gold reached above $1,800 in 2011 only to drop to below $1,100 in 2015. The price of gold declined to nearly $250 an ounce in 1999 in the midst of the dot-com bubble.

Wiener’s advice on gold is simple: “The best investment you can make in gold is to hang some around the neck of someone you love.”