Gold futures reversed course just ahead of Wednesday’s settlement to finish with a modest decline as U.S. equities climbed and the dollar strengthened in the wake of Republican candidate Donald Trump’s election win.

The yellow metal had been trading higher, though off session’s best levels, as the uncertainty surrounding Trump’s stunning victory against Democratic rival Hillary Clinton prompted investors to seek out less risky assets.

Gold futures for December delivery US:GCZ6 fell $1, or less than 0.1%, to settle at $1,273.50 an ounce.

Prices had advanced to as high as $1,338.30 an ounce, up nearly $64, or 5%, as the election results rolled in late Tuesday and early Wednesday. The market hadn’t seen a single-session rise of that size since the day after the U.K.’s surprise vote to leave the European Union. Trump’s presidential victory was drawing comparisons with that event this summer.

“With much to learn about the new president’s advisors and policies, gold price swings will likely reflect the ebb and flow of this uncertainty,” said Rob Haworth, senior investment strategist at U.S. Bank Wealth Management.

Read:Why gold failed to rally after Trump’s win

Uncertainty, as well as volatility, were key in Wednesday’s trading as financial markets digested the news of the Trump win.

U.S. equities went from hefty losses to big gains, while the dollar DXY, +0.32% weakened, then strengthened. The risk-on sentiment supporting equities and the greenback Wednesday drew investor attention away from gold.

Still, most analysts expect Trump’s win to fuel gains for the yellow metal in the next few weeks.

“Investors will likely be looking for uncorrelated, safe-haven assets as it searches for ways to insulate their portfolio from possible tail risks related to a Trump presidency,” said Shree Kargutkar, associate portfolio manager at Sprott Asset Management.

He said he expects to see “a positive tone for gold as it looks to maintain its footing above $1,300 heading into year end and looks to move higher in 2017.”

Indeed, prices for the yellow metal soared during the Asian trading hours as Asia experienced a “classic knee-jerk reaction to a significant event,” GFMS team at Thomson Reuters said in a note Wednesday.

How markets responded to Trump's victory

But “it should not come as a surprise that some miners would wish to lock into a smart rally, nor that there should be some investor selling in china as holders who had previously bought in the $1,300 region took advantage of the opportunity to take some profits,” the GFMS team said.

While the polls were pointing to a tight race between Trump and Clinton, financial markets had in recent days started to price in a Democratic victory, sending global equities and the dollar sharply higher.

Clinton was generally considered the better choice for financial markets in the short term, because she is seen as representing the status quo for investors, and is viewed as more open to international trade than her GOP rival.

Analysts had argued that a Trump victory would make a Federal Reserve rate increase in December less likely.

“An additional uncertainty now revolves around interest-rate policy,” said the GFMS team. Trump is “already intimating that he may not renew FOMC Chair Janet Yellen’s post when her first term ends in 2018—and this has prompted some speculation that she may go sooner.”

In other metals, December silver US:SIZ6 added 2.2 cents, or 0.1%, to $18.378 an ounce, giving up much of the earlier gains that brought prices to as high as $19. Palladium for the same month US:PAZ6 rose $15.95, or 2.4%, to $681.45 an ounce, while platinum for January US:PLF7 fell $5.30, or 0.5%, to $1,003.30 an ounce. December US:HGZ6 tacked on 8 cents, or 3.3%, to $2.46 a pound.

Among the exchange-traded funds, the SPDR Gold Trust GLD, -1.97% rose 0.9%, while the VanEck Vectors Gold Miners ETF GDX, -5.52% added 4.3%.

Read:Gold investment demand jumps world-wide, but overall demand drops

—Mark DeCambre contributed to this article