By DAMIAN J. TROIS and ALEX VEIGA

NEW YORK (AP) — Stocks rocked a midday drop and ended higher Thursday, keeping the market on track for its first weekly gain after three weeks of punishing losses.

Trading was choppy throughout the day as investors remained focused on another round of testimony before Congress from Federal Reserve Chairman Jerome Powell. Speaking before a House committee, Powell again stressed that the Fed hopes to rein in the worst inflation in four decades without plunging the economy into a recession, but acknowledged that “that path has become increasingly difficult” .

The S&P 500 ended up 1% after losing as much as 0.4%. The Dow Jones Industrial Average rose 0.6% and the Nasdaq gained 1.6%.

Technology and healthcare stocks drove much of the rally, offsetting losses in energy and financial companies. Bond yields have mostly fallen. Oil prices also fell.

Trading has been turbulent in recent weeks as investors try to determine if a recession is looming. The benchmark S&P 500 index is currently in a bear market. This means that it has fallen more than 20% from its most recent peak, which was in January. The index has fallen for 10 of the past 11 weeks.

“The market was about to rebound,” said Quincy Krosby, chief equity strategist for LPL Financial. “The catalyst for the current market has been falling oil prices.”

The S&P 500 rose 35.84 points to 3,795.73. The index is up 3.3% since the start of the week. The Dow gained 194.23 points to 30,677.36. The Nasdaq added 179.11 points to 11,232.19.

Small company stocks also gained ground. The Russell 2000 rose 21.40 points, or 1.3%, to 1,711.67.

The Federal Reserve is trying to soften the impact of inflation with higher interest rates, but Wall Street fears it will go too far in slowing economic growth and triggering a recession.

Powell has previously acknowledged that a recession is “certainly a possibility” and that the central bank faces a tougher task amid the war in Ukraine, essentially pushing oil and other commodity prices even higher and making inflation even more pervasive.

On Thursday, Powell stressed, “I don’t think a recession is inevitable.” He also acknowledged that the Fed’s tools to fight inflation are blunt and risk damaging the economy.

Encouragingly for the Fed, many households and businesses still seem to be expecting inflation to come down eventually. If that were to change, it could trigger a self-fulfilling vicious cycle that would only make inflation worse.

“Our whole framework is aimed at keeping inflation expectations well and truly anchored,” he said on Thursday. Powell stressed the importance of bringing inflation back to the Fed’s 2% target. “We can’t fail on this,” he said.

Powell addressed Congress a week after the Fed raised its benchmark interest rate by three-quarters of a percentage point, its biggest hike in nearly three decades. Fed policymakers are also forecasting a faster pace of rate hikes this year and next than they expected three months ago, with its key rate expected to hit 3.8% by the end of the year. of 2023. That would be its highest level in 15 years.

Earlier Thursday, the Labor Department said fewer Americans filed for unemployment benefits last week, though that was slightly more than economists expected. The strength of the job market is a relatively positive element in an otherwise weakening economy, with consumer confidence and retail sales showing increasing damage from inflation.

Companies are, however, reporting slower-than-expected growth, according to IHS Markit surveys. While weak economic data is disheartening for the wider economy, it could also mean that the economy is already slowing enough to allow the Fed to ease its planned rate hikes.

Inflation remains stubbornly high, overwhelming consumers with higher prices on everything from food to clothes. This has caused people to shift spending from big items like electronics to basic necessities. The pressure has been compounded by record gasoline prices that show no signs of abating amid a disconnect in supply and demand.

Big tech and healthcare companies have done much of the heavy lifting. Microsoft rose 2.3% and Johnson & Johnson 2.2%. Energy stocks fell as the price of US crude oil fell 1.8%. Valero fell 7.6%.

Bond yields fell significantly. The yield on the 10-year Treasury note, which helps fix mortgage rates, fell to 3.09% from 3.15% on Wednesday evening.

___

AP Business Writer Stan Choe contributed. Veiga reported from Los Angeles.