Gold futures rallied on Friday to finish at their highest level in nearly two years as investors rushed to buy the metal in the wake of the U.K.’s decision to exit from the European Union.

Gold tends to rally in times of economic, market or political uncertainty because precious metals are considered a haven asset. As might be expected, riskier assets, including U.S. stocks, tumbled.

“Global growth is unstable right now and the U.K. leaving the EU only adds to the instability,” Frank Holmes, chief executive officer and chief investment officer of U.S. Global Investors, told MarketWatch. “With that, we see that gold is sound money.”

August gold US:GCQ6 jumped $59.30, or 4.7%, to settle at $1,322.40 an ounce with prices marking the largest single-session dollar and percentage climb since September 2013. The settlement was highest since July 11, 2014, according to FactSet data.

Gold futures traded as high as $1,362.60. That’s nearly $100 an ounce above Thursday’s settlement, which marked a fifth-straight session decline. For the week, gold was up 2.1% after settling last Friday at $1,294.80.

July silver US:SIN6 rallied by 43.6 cents, or 2.5%, to $17.789 an ounce, with prices set for the highest settlement since late April. The metal saw a 2.2% weekly gain.

Read:Why gold may hit $1,500 by year’s end—and it’s not just about Brexit

The U.K.’s surprising decision to leave the EU has “introduced a lot of uncertainty and volatility in the global financial markets,” said Maria Smirnova, portfolio manager at Sprott Asset Management, which offers the Sprott Gold Miners exchange-traded fund SGDM, -2.04% .

“We are in a risk-off environment. The possibility of a [U.S. Federal Reserve] rate hike is zero to December,” she said. “While we will not know the full implications of this [Brexit] decision for months or even years, it is highly positive for gold and silver.”

Among the ETFs, the SPDR Gold Trust GLD, +0.13% was up 4.8% shortly after gold futures settled Friday. The VanEck Vectors Gold Miners ETF GDX, -1.75% also shot up 6.5%.

“Gold ETF holdings have increased sharply and it’s a trend we expect to see accelerate as both retail an institutional investors reallocate funds to gold,” the World Gold Council said in a statement Friday.

Gold had pulled back during recent trading sessions in the wake of pre-vote polling that signaled a slight edge for the “remain” camp. The referendum results sent the pound to 1980s levels and roiled most global markets.

Read:The U.K. has voted for Brexit — what happens next?

“ ‘When you are caught on the wrong side, this is what you do: sell everything and look for safe havens.’ ” — Naeem Aslam, ThinkForex

“When you are caught on the wrong side, this is what you do: sell everything and look for safe havens,” said Naeem Aslam, chief market analyst at ThinkForex.

The U.S. Dollar Index DXY, +0.03% , the measure of the buck against a basket of currencies, was up 2%. The dollar and gold often move inversely, but as other vote-sensitive currencies moved lower against the dollar, the greenback logged short-term gains that unhooked the currency from its typically inverse relationship with gold.

“This is just the kind of crisis [that] gold helps savers and investors insure against,” said Adrian Ash, head of research at BullionVault. “Gold offers certainty and security as stock markets and currencies sink, just as it did during the 2008 meltdown. The difference is that this shock was clearly signposted and many private investors didn’t wait for today’s result to get prepared.”

Other analysts expected the gold-supportive reaction to ease off, although most expect the metal to remain underpinned until the interest-rate debate heats up again.

“We would not be surprised to see gold hit our existing end-2017 target of $1,400 per ounce much sooner if market jitters do continue to grow,” said Julian Jessop, head of commodities research, at Capital Economics. “However, if we are right that the vote for Brexit is not the global shock that many fear, U.S. interest-rate hikes could soon be back on the agenda.”

He added: “Gold should still do well in this scenario, buoyed by growing appetite for inflation hedges and robust demand from emerging economies, but clearly not as well as if the world were indeed heading for disaster.”

July copper US:HGN6 fell 5.2 cents, or 2.4%, to $2.111 a pound, pressured by expectations of weaker demand for the industrial metal. It was still up about 2.9% for the week.

July platinum US:PLN6 added $20.80, or 2.2%, to $987.10 an ounce, ending 2.2% higher on the week, while Sept. palladium US:PAU6 dropped $19.45, or 3.4%, to $546.45 an ounce — cutting its gain for the week down to around 3.2%.