Stocks finished a volatile day slightly higher on Monday after reversing a steep slide caused by uncertainty over inflation-fighting measures from the Federal Reserve and the possibility of conflict between Russia and Ukraine.

A late-day buying spree pushed the benchmark S&P 500 index to a 0.3% gain after pulling it out of so-called correction territory — a drop of 10% or more from its recent high. The Dow Jones Industrial Average had declined more than 1,000 points before rallying and ending higher.

Monday’s wild turnaround followed a three-week decline for the S&P 500, concluding with its worst weekly stretch since the start of the pandemic.

The S&P 500 had been down as much as 4% Monday. The index has recovered from an intraday loss that big only three times in the past. The tech-heavy Nasdaq index rose 0.6% after recovering from a nearly 5% descent.

Early in the day, benchmark stock indexes flirted with near 4-month lows as investors anticipated guidance from the Fed later this week about its plans to raise interest rates to tame inflation, which is at its highest level in nearly four decades.

The S&P 500 rose 12.19 points to 4,410.13. It’s now 8.1% below the all-time high it set on Jan. 3. The Dow rose 99.13 points to 34,364.50. The Nasdaq gained 86.21 points to 13,855.13.

Small-company stocks also bounced back. The Russell 2000 rose 45.59 points, or 2.3%, to 2,033.51. The index had been down 2.8%.

Bond yields mostly rose after falling earlier in the day. The yield on the 10-year Treasury rose to 1.77% from 1.74% late Friday.

On Tuesday, American Express, Johnson & Johnson, and Microsoft reported results. Boeing and Tesla will report their results on Wednesday. McDonald’s, Southwest Airlines and Apple will report results on Thursday.