U.S. stocks came close to making financial history Thursday, soaring toward record highs before slipping in late-day trading.

The Standard & Poor’s 500 index has been on a remarkable turnaround since late March, when equities markets got hammered by the economic calamity of the coronavirus.

The benchmark index — which offers a broader measure of the stock market than the Dow Jones industrial average — has been flirting with its February record of 3,386.15 for several trading days. It briefly topped that level Thursday before falling back.

The ferocity of the rebound has been underpinned by massive financial support from the federal government, said Nicole Tanenbaum of Chequers Financial Management, allowing investors to look toward an eventual recovery. “Economic data, while still at dire levels, is starting to show signs of stabilization, which, combined with a better than expected earnings season, is further fueling investor optimism despite an incredibly uncertain backdrop,” she said.

For individual investors whose exposure to the stock market is exclusively or partially tied to their 401(k) retirement plans, the recovery marks a return to pre-pandemic highs. “The average 401(k) holder is feeling pretty good right now,” Michael Farr, president of Farr, Miller & Washington, said in an interview. But he noted the jarring contrast between the soaring ambitions of Wall Street and the dire conditions for many businesses and households pummeled by the pandemic.

“We have seen this separation and disconnect that has been disconcerting to some investors where share prices continue to rise but the economic data and an economic recovery remains tepid,” he said. “You’re coming up on all-time highs when you still have 10 percent unemployed — that’s a huge deal.”

In the final hour of trading Thursday, the S&P 500 edged down 6.9 points, or 0.2 percent, to 3,373.43. The Dow gave up 80.12 points, or 0.29 percent, to settle at 27,896.72. The tech-heavy Nasdaq composite index, which has been buoyed by the tech giants and recently set its own record, advanced 30.26 points, or 0.3 percent, to 11,042.50.

The slight losses came as weekly jobless claims dipped below 1 million for the first time in four months, though they remain at historically high levels.

The U.S. Labor Department reported that 960,000 Americans filed for unemployment insurance last week, compared with 1.18 million the week before. Before the pandemic, the record stood at 695,000, which was set during the 1982 recession. Altogether, more than 28 million people are receiving some form of unemployment benefits, government data show.

The rising optimism on Wall Street clashes with other data highlighting the devastating effects of the pandemic. Wednesday marked the deadliest day of the summer as the United States recorded nearly 1,500 coronavirus deaths — the largest single-day count since mid-May and the latest signal that the contagion is far from under control.

U.S. stocks lost more than a third of their value between Feb. 19 and March 23, when the pandemic set off panic and weeks of wild intraday swings. The stunning turnaround continues to defy the entrenched recession and stalled efforts in Washington to pass another round of emergency relief.

Investors instead have focused on aggressive actions by the Federal Reserve and the Treasury, which have marshaled far more financial resources to stem the damage of the pandemic compared with their interventions during the Great Recession. They’ve also found room for optimism in corporate earnings that showed better-than-expected resilience, and the potential for a coronavirus vaccine.