"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 broke below and then sharply bounced 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.

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, is trading around 2.84% on Friday.

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."

Crude oil prices have also retreated during the market turmoil. Crude slumped 3% on Friday and slipped below $60 a barrel for the first time this year. Oil prices have now lost more than 10% of their value from the peak in late January.

The ferocity of the selling has 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 36% 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.