Wall Street capped a week of violent swings with a big gain.
The Dow climbed 330 points on Friday in another extremely turbulent day of trading. At one point the index was down 500 points. At another it was up 500.
Fears about inflation and soaring bond yields drove the Dow down about 1,300 points on the week. The 5.2% sell-off was the worst weekly decline in two years.
All week, the market gyrated between large gains and even larger losses. There were two 1,000-point declines for the Dow, as well as the index's fourth-biggest gain ever.
"We've gone from very calm to very volatile in a short period of time," said Matt Forester, chief investment officer at BNY Mellon's Lockwood Advisors.
Had the Dow lost any ground on Friday, it would have been the index's worst week since October 2008, during the financial crisis.
"The trigger has been the really fast rise in bond yields," said Evan Brown, director of asset allocation at UBS Asset Management.
Investors breathed a sigh of relief when the S&P 500 dipped below and then bounced sharply above a crucial level of support known as the 200-day moving average. A close below that level, around 2,538, could have touched off even more selling.
Although the weekly losses came close to the scary days of the crisis, the market and economy are in vastly better shape than in 2008. Unemployment is the lowest in 17 years, and the banking system has mostly healed.
The recent turmoil follows a prolonged period of booming stock prices with virtually no sharp declines. Such a rapid rise is unusual, and market analysts long warned that a pullback was overdue.
"It's been way too calm," Forester said.
Related: Stocks flew too close to the sun. Now what?
The S&P 500's market value surged $6 trillion between President Trump's election and the all-time high on January 26. The rout erased $2.5 trillion in value from the S&P 500 and $5.2 trillion from global stocks, according to S&P Dow Jones Indexes.
The jitters have been driven by the rapid rise in 10-year Treasury yields. Selling in the bond market led Wall Street to worry that inflation will force the Federal Reserve to speed up its rate hike plans.
The 10-year Treasury yield, which touched a four-year high of 2.88% on Thursday, closed out the week at 2.85%.
One new source of pressure on bonds is the budget deal that Trump signed on Friday. The bipartisan agreement boosts federal spending limits by $300 billion over the next two years. The federal budget deficit could top $1 trillion in fiscal 2019, according to Bank of America.
To pay for the spending spree, the Treasury Department will be forced to borrow even more money by selling additional bonds. Rates may have to go up to attract buyers for those bonds.
The budget deal could stimulate the economy even more over the next 10 years than last year's tax cut, Brown said. Because the economy is already strong, that boost from Washington could speed up inflation.
"You are at full employment, and the government is engaging in significant fiscal stimulus," Brown said. "There are concerns that this is not the ideal time to be increasing fiscal expansion. The market is pricing in potential for some overheating."
Nicholas Colas, co-founder of DataTrek Research, doesn't think the sell-off will end until bond yields fall sharply.
"Too late to sell, too early to buy ... That feels like where we are," Colas wrote in a report. "Stocks won't bottom until long term Treasuries rally hard."
Related: This is why the Dow is plunging
The ferocity of the selling caught investors off guard.
The boom carried the stock market so high that it was considered "extremely overbought" based on technical factors. But the plunge has left the S&P 500 "extremely oversold," according to Bespoke Investment Group. Such a dramatic swing in the span of just two weeks is very rare.
While the market turbulence can be alarming, analysts urged investors to stay calm because the economic backdrop is strong. The unemployment rate is 4.1%, a 17-year low, and economic growth is expected to gain steam in 2018.
"The last thing anybody should do is overreact to traditional volatility," said Rich Guerrini, CEO of PNC Investments.
Despite the heavy losses this week, the Dow remains up 32% since Trump's election.
"The outlook for the economy is extremely positive, the strongest in a long, long time," said Doug Cote, chief market strategist at Voya Investment Management.
"Based on fundamentals, this is a buying opportunity," he said.