NEW YORK (AP) — The stock market clawed back from a midday drop Friday after coming to the edge of its first bear market since the beginning of the pandemic. The S&P 500 ended 18.6% below the record high it set in early January. A 20% decline would have been considered the beginning of a bear market. The benchmark index, the heart of many retirement accounts, came back from a loss of 2.3% to end just barely in the green. Rising interest rates, high inflation, the war in Ukraine, and a slowdown in China’s economy have been worrying investors. The Dow erased a 600-point drop.

THIS IS A BREAKING NEWS UPDATE. AP’s earlier story follows below.

NEW YORK (AP) — Another fall for stocks on Friday has the S&P 500 flirting with a 20% drop from its peak set early this year, putting it within the grasp of what Wall Street calls a bear market.

The index that’s at the heart of most workers’ 401(k) accounts was down 0.4% for the day in afternoon trading and on pace for its seventh straight losing week, which would be its longest since 2001.

Rising interest rateshigh inflation, the war in Ukraine, and a slowdown in China’s economy are all punishing stocks and raising fears about a possible U.S. recession. Compounding worries is how the superhero that’s flown to Wall Street’s rescue in the most recent downturns, the Federal Reserve, looks less likely to help as it’s stuck battling the worst inflation in decades.

If the S&P 500 finishes the day 20% or more below its record, it would mark the first bear market since early 2020, when the pandemic sparked an unusually brief downturn that sliced 34% off the S&P 500. It gave way to a powerful run where the S&P 500 more than doubled, drawing in a new generation of investors who met seemingly every wobble with the rallying cry to “Buy the dip!”

“I think plenty of investors were scratching their heads and wondering why the market was rallying despite the pandemic,” said Brian Jacobsen, senior investment strategist at Allspring Global Investments. “Now that the pandemic has hopefully mostly passed, I think a lot of investors are kicking themselves for not having gotten out on signs that the economy was probably slowing and the Fed was making its policy pivot.”

With inflation at its highest level in four decades, the Fed has aggressivly flipped away from keeping interest rates super-low in order to support markets and the economy. Instead it’s raising rates and making other moves in hopes of slowing the economy enough to tamp down inflation. The worry is if it goes too far or too quickly.

“Certainly the market volatility has all been driven by investor concerns that Fed will tighten policy too much and put the U.S. into a recession,” said Michael Arone, chief investment strategist at State Street Global Advisors.

The S&P 500 was 0.4% lower, with 20 minutes left to go in the trading day, or 19% below its record set on Jan. 3. Earlier in the day, it was down more than 20%. The Dow Jones Industrial Average fell 364 points, or 1.2%, to 30,888 and the Nasdaq was 2%.

Bond yields fell as recession worries pushed investors into Treasurys and other things seen as safer. The yield on the 10-year Treasury note, which helps set mortgage rates, fell to 2.78% from 2.85% late Thursday.

Inflation has been painfully high for months. But the market’s worries swung even higher after Russia’s invasion of Ukraine sent prices spiraling further at grocery stores and gasoline pumps, because the region is a major source of energy and grains. The world’s second-largest economy, meanwhile, has taken a hit as Chinese officials locked down key cities in hopes of halting COVID-19 cases. That’s all compounded with some disappointing data on the U.S. economy, though the job market remains hot.

Adding pressure onto stocks have been signs that corporate profits are slowing and may finally getting hurt by inflation. Retail giants Target and Walmart both had warnings this week about inflation cutting into finances. Discount retailer Ross Stores plunged nearly 23% on Friday after cutting its profit forecast and citing rising inflation as a factor.

“The latest earnings from retail companies finally signaled that U.S. consumers and businesses are being negatively impacted by inflation,” Arone said.

Although its source is different, the gloom on Wall Street is mirroring a sense of exasperation across country. A poll from The Associated Press-NORC Center for Public Research released Friday found that only about 2 in 10 adults say the U.S. is heading in the right direction or the economy is good, both down from about 3 in 10 a month earlier.

Much of Wall Street’s bull market since early 2020 was the result of buying by regular investors, many of whom started trading for the first time during the pandic. Alongside many cryptocurrencies, they helped drive darlings like Tesla’s stock higher. They even got GameStop to surge suddenly to such a high level that it sent shudders through professional Wall Street.

But these traders, called “retail investors” by Wall Street to differentiate them from big institutional investors, have been pulling back as stocks have tumbled. Individual investors have turned from a net buyer of stocks to a net seller over the last six months, according to a recent report from Goldman Sachs.

Robinhood Markets, whose easy-to-use trading app helped draw millions of new investors, has seen its huge growth in revenue reverse amid fewer trades by nervous customers, particularly those with smaller balances.