The Dow Jones Industrial Average rallied to a record close on Thursday as investors continued to revise their strategies and reposition portfolios in response to Donald Trump’s unexpected presidential election victory.

The blue chip index DJIA, -1.63% gained 218.19 points, or 1.2%, to finish at 18,807.88 after hitting an all-time high of 18,873.66 earlier. The S&P 500 index SPX, -1.95% rose 4.22 points, or 0.2% to end at 2,167.48.

“Trump made rebuilding the nation’s infrastructure a centerpiece of his campaign. As such, the market is expecting an emphasis on fiscal spending initiatives to jump-start the economy,” said Michael Reilly, chief investment officer for equities at TCW.

Read:Trump stock rally signals new era of fiscal stimulus

The Nasdaq Composite Index COMP, -2.60% trimmed losses but fell 42.28 points, or 0.8%, to close at 5,208.80. It was down more than 100 points at one point during the session.

“We are witnessing the unwind of the ‘presidential trade,’” said Ian Winer, director of equity trading at Wedbush Securities, referring to the decline in tech shares.

Investors had largely positioned themselves for a win by Hillary Clinton but were forced to adjust portfolios quickly in the wake of the stunning Trump upset, he said.

The Nasdaq is heavily weighted toward technology names, which were among the weakest sectors of the day, off about 2.2%. Among the top decliners of the space, Qualcomm Inc. QCOM, -2.61% fell 2.3% while Broadcom Ltd. AVGO, -2.17% lost 3.2% and Facebook Inc. FB, -1.89% dropped 1.9%.

“If I am a portfolio manager and need to move my exposures quickly, I sell big cap techs to raise money,” Winer said. “The number of investors who have called me asking me about this trade and the clear pain out there tells me that we are in the seventh inning of this unwind.”

The volatility isn’t surprising since investors were expected to continue digesting Trump’s historic victory and the impact it could have on economic policy, strategists said. Although some feared a win for the Republican candidate would spark severe market volatility, stocks shook off their initial jitters and closed higher in Europe and the U.S. on Wednesday.

“There was an initial reaction to speculation on issues like fiscal stimulation, for example, but as we get into the coming days and weeks, we’ll need to rethink a lot of our initial reactions,” said Bruce McCain, chief investment strategist at Key Private Bank. “There are a lot of things we don’t know, and while it’s tempting to speculate, we need more evidence before we know whether we should zig or zag.”

Trump’s presidency is seen as potentially providing a boost to financial and industrial stocks, partly because of his plan to increase fiscal spending to fund infrastructure projects. If instituted, that will benefit construction companies, as well as help banks because bond yields are expected to rise. A possible move toward lighter regulation is also seen helping financial firms.

Shares in those sectors were the biggest advancers on Wednesday, and they continued higher on Thursday. Caterpillar Inc. CAT, -1.92% rose 2.5%, while Goldman Sachs Group Inc. GS, -2.40% and Bank of America Corp. BAC, -1.90% both advanced more than 4%.

Pharmaceutical stocks also gained on the prospect that a Trump administration will be less restrictive on drug pricing than Clinton might have been. Shares of Pfizer Inc. PFE, -0.06% shares rallied 4.3% and Merck & Co. MRK, +0.12% shares advanced 1.2%.

Macy’s Inc. M, -1.67% reported third-quarter earnings that fell from the prior year and missed expectations. Still, shares of the company jumped 5.6%.

Among other markets, Asian stocks also rebounded sharply. The Nikkei 225 index NIK, -0.05% closed 6.7% higher for its biggest gain since February while European stocks were mostly lower.

The ICE Dollar Index DXY, +0.45% rose 0.3%, recovering from a 0.2% loss on Wednesday, and the 10-year Treasury note TMUBMUSD10Y, 0.676% fell further with the yield rising 8.22 basis points to 2.137% after a dramatic jump in the previous session.

Michael Moore joins NYC anti-Trump protest

Economic news: First-time jobless claims fell more than expected in the latest week, keeping the rate of layoffs near the lowest levels in decades.

Other markets: Oil turned lower after the International Energy Agency warned of “relentless” growth in oil supply in 2017. Crude CLZ26, -1.13% slid more than 1% and gold US:GCZ6 extended losses following Wednesday’s choppy session.

--Sara Sjolin contributed to this report.