Stocks soared Thursday as investors applauded signs that power in Washington could be divided between a Democratic president and a Republican Senate determined to block his most ambitious proposals.

The Dow Jones industrial average rose 542 points, or 2 percent, to close at 28,390. The broader S&P 500 also rose about 2 percent, while the technology-rich Nasdaq jumped 2.6 percent and has gained 6.5 percent in the past two sessions.

All three markets are headed for their best weekly performances since April.

Officials in several undecided battleground states continued counting votes two days after the election. But former vice president Joe Biden was nearing the requisite 270 electoral votes needed to become the next president, and Republicans appeared poised to retain control of the Senate.

If that outcome is confirmed, Biden’s plans to increase taxes on corporations and high-income individuals and enact sweeping regulatory changes and launch green-energy projects would be unlikely to survive. Senate Majority Leader Mitch McConnell (R-Ky.) would be able to block market-rattling Cabinet appointments, such as Sen. Elizabeth Warren (D-Mass.) as treasury secretary. Investors also could anticipate a less erratic policymaking process if President Trump is defeated.

Tuesday’s elections may have disappointed partisans on both sides of the aisle, but money managers cheered the return of gridlock.

“It’s probably the goldilocks scenario,” said Michael Mussio, president of FBB Capital Partners in Bethesda.

Markets were quick to react to the unsettled election results, with the stocks of health insurers and drugmakers jumping on the assumption that McConnell would block aggressive policy moves. Shares of insurer United Health Group rose 10 percent Wednesday before hitting a 52-week high Thursday, while shares of energy companies such as First Solar sank amid fading hopes for Democrats’ Green New Deal.

“That’s the anti-AOC trade,” said Mussio, referring to Rep. Alexandria Ocasio-Cortez, (D-N.Y.), a champion of renewable energy.

In the campaign’s final days, as pundits forecast a “Blue Wave” delivering unified Democratic control at both ends of Pennsylvania Avenue, investors counted on Biden to produce a multitrillion-dollar stimulus bill early next year. Divided government is likely to mean a less generous package, but some investors say it could be enough to revive the slowing recovery.

McConnell said Wednesday that he favored producing a new economic rescue package before the end of the year. The Trump administration and House Speaker Nancy Pelosi (D-Calif.) negotiated for months over a potential $2 trillion deal without reaching agreement. Any legislation produced in the next several weeks could center on additional unemployment insurance benefits, small-business loans and checks for taxpayers.

“The headline number is likely to be much lower,” said David Page, head of macro research for AXA Investment Managers in London. “But the kernel of what’s likely to come through will feed into the economy in the short term.”

Some market professionals urged caution as Trump escalated his scorched-earth legal strategy to challenge results in several key states, threatening weeks of uncertainty before an official outcome.

“It’s a little bit odd we’re this excited when we don’t know what’s happening,” said Liz Young, the director of market strategy for BNY Mellon Investment Management in New York.

Biden held a 253 to 214 advantage in electoral votes over Trump on Thursday as vote counting continues in Alaska, Arizona, Georgia, Nevada, North Carolina and Pennsylvania, according to multiple news organizations.

“It seems that Wall Street might get unofficial results fairly soon,” Ed Moya, an analyst with OANDA, said via email. “The contest is not over, and President Trump will not go down without a fight, but financial markets are confident to price in a Biden presidency along with a Republican-controlled Senate.”

The Trump campaign said Wednesday that it would launch a legal blitz to try to halt vote-counting in Pennsylvania and Michigan, would seek a recount in Wisconsin and challenged the handling of ballots in Georgia, threatening to draw out a resolution of the contest. But investors on Wall Street and overseas seemed unconcerned.

“We have no doubt when the count is finished, Senator Harris and I will be declared the winner,” Biden said Thursday in Delaware.

Asian markets closed higher across the board Wednesday, with Hong Kong’s Hang Seng Index advancing 3.3 percent to post its best performance since July. Japan’s Nikkei 225 climbed 1.7 percent, and the Shanghai Composite index gained 1.3 percent.

European indexes all advanced in midday trading.

“A new administration in the White House may well dial down tensions with other global superpowers on issues like trade,” Russ Mould, the investment director at AJ Bell, said via email. “This certainly seemed to be the thinking in Asia overnight as Japanese and Chinese equities staged substantial rallies."

Even as the vote counting continued, the United States shattered coronavirus records Wednesday, reporting more than 104,000 new infections in a single day. Meanwhile, 18 states — including Kansas, Tennessee, Virginia, Oklahoma, Montana, Iowa, North Dakota, South Dakota, Ohio, Nebraska, Minnesota, Indiana, Wisconsin and West Virginia — reported record numbers of hospitalizations because of the virus that has killed at least 234,000 Americans since February, according to data tracked by The Washington Post.

The pandemic’s surge could stall the economic recovery, which is showing signs of tapering. About 751,000 Americans filed new unemployment claims for the week ending on Oct. 31, the Labor Department reported Thursday. That’s down from last week, but with 21.5 million people drawing unemployment aid, joblessness in the United States remains at crisis levels.

“Election uncertainty is moving back down, but employment uncertainty remains high,” said Chris Rupkey, the chief financial economist at MUFG Union Bank. “Jobless claims continue at higher levels than the peak of the Great Recession over a decade ago.”

Friday’s monthly jobs report is expected to show a decline in unemployment in October.