Gold is shining again as investors scramble for safety amid the widening global trade war.

The price of gold has climbed nearly 5% since May 21, while markets around the world fell. Last week was the best of the year for gold after President Donald Trump surprised markets by threatening to raise tariffs on Mexico.

It’s not all that surprising, because gold has often served as a safe haven when markets are tumbling. During the wrenching 2007-09 downturn, gold climbed 23.5% when the S&P 500 lost 55.2%. Gold also managed to eke out gains during the summer of 2011, when worries about the European debt crisis and the downgrade of the U.S. credit rating nearly felled the bull market for U.S. stocks.

But gold didn’t immediately provide solace for investors after Trump shattered the market’s calm in early May with a tweet threatening escalating tariffs against China. In fact, until last week gold had been on pace to sink in May.

It’s part of a longstanding trend. Gold has been cycling back and forth between roughly $1,000 per ounce and $1,400 for the last six years, and it’s still down nearly 30% from its record set in 2011 at $1,891.90.

Instead of gold, bond funds have offered much softer landing pads for investors this year. Like gold, bonds have a reputation for offering someplace safe to hide when the stock market is tumbling. Unlike gold, bonds also pay their owners interest.

The price of gold has shuffled between $1,270 an ounce and $1,350 an ounce this year, and analysts say that’s partly because of the strengthening value of the U.S. dollar. The two often move in opposite directions, and the dollar has climbed against the euro and other currencies this year, though the gains have pared recently.

Gold also tends to do best when inflation — or concern about it — is high, and they’ve been largely non-existent. An ultralow unemployment rate hasn’t been enough to push wages higher and feed through into higher prices across the economy. Some investors even say that deflation — when prices are dropping — may be a bigger threat than high inflation.

Analysts at J.P. Morgan say gold’s price could continue to rise, and they’re forecasting an average price of $1,405 per ounce in the last three months of the year. That would be up 5.3% from Wednesday’s settlement price of $1,333.60. Stifel strategist Barry Bannister says the price may rise to $1,350 per ounce by the end of the year.

One potential wild card, though, lies in another projection that Bannister and others on Wall Street are increasingly making: that the Federal Reserve cuts interest rates not just once but twice this year. Fed rate cuts often spur concerns about potential inflation, which helps the price of gold.

Since the end of 2015, the Fed had been moving in the opposite direction, as it pulled rates higher to get them closer to normal following the Great Recession’s aftermath. It hit the pause button at the start of this year, and many investors had been expecting it to hold there for a while.

But the trade war may be denting business confidence, which would cause delays in spending and drag on the economy. That has investors increasingly forecasting cuts to interest rates, and those hunches may end up proving correct.

Fed Chairman Jerome Powell said on Tuesday that the central bank is ready to respond in case the trade war threatens the economy. Investors read that as a signal for possible rate cuts. So, there’s a chance gold will glitter more.

© The Associated Press. All rights reserved.