The U.S. stock market mounted a last-minute comeback to close slightly higher Monday, snapping a three-day losing streak.
The Standard & Poor's 500 index and the Dow Jones industrial average each eked out a tiny gain, while the Nasdaq composite ended slightly lower.
Consumer staples stocks were among the biggest gainers. Oil and gas companies were hit by another plunge in the price of crude oil, which tumbled 5.3% to a 12-year low. Chevron lost 1.7%, and Exxon Mobil fell 1%.
The latest downturn in oil comes at a time when investors are increasingly uneasy about the trajectory of China's economy and the possible implications for U.S. company earnings. China's Shanghai composite fell 5.3% on Monday.
"Investors have one eye on China and all that's going on there, and the other eye on oil," said Erik Davidson, chief investment officer at Wells Fargo Private Bank. "Those two things are keeping investors on pins and needles right now."
The Dow climbed 52.12 points, or 0.3%, to 16,398.57. The S&P 500 index rose 1.64 points, or 0.1%, to 1,923.67. The Nasdaq fell 5.64 points, or 0.1%, to 4,637.99.
All of the major stock indexes are down sharply for the year.
The three indexes hinted at a rebound early Monday, but spent much of the day in the red as investors weighed the implications of another stock market drop in China and the slide in crude. The market appeared headed for a lower close until the final minutes of regular trading, when the Dow and S&P 500 index shifted back into positive territory.
Monday's market action is a slight reprieve from an otherwise rough year so far for investors.
Last week, U.S. stocks posted their worst week in more than four years. It was also the market's worst-ever opening week of a year.
A weakening of China's currency and steep drops in its stock market have stoked worries over the outlook for the world's second-largest economy.
That doesn't bode well for the next round of company earnings, which kicks into gear this week.
Many companies' quarterly results are likely to reflect the effect of China's softening economy and lower oil prices, said Jason Pride, director of investment strategy at Glenmede.
"The No. 1 most-mentioned item in third-quarter reports was weakness in China," Pride said. "We'd be surprised if China and oil are not central to the earnings narrative as well."
Alcoa delivered its report card after the close of regular trading Monday. The earnings were better than analysts had expected. Several banks, including Citigroup, Wells Fargo and J.P. Morgan, are scheduled to report results toward the end of the week.
On Monday, Benchmark U.S. crude dropped $1.75, or 5.3%, to $31.41 a barrel in New York. The last time it was lower was Dec. 5, 2003, when it closed at $30.73 a barrel. Brent crude, a benchmark for international oils, fell $2, or 6%, to $31.55 a barrel in London.
Several energy and mining companies slumped as crude oil and other commodity prices fell.
Freeport-McMoRan dived $1.10, or 20.3%, to $4.31, making it the biggest decliner in the S&P 500 index. Consol Energy also slumped, sinking 69 cents, or 9%, to $7. NRG Energy shed $1.11, or 9.8%, to close at $10.23.
Chevron slid $1.36, or 1.7%, to $80.77, and Exxon Mobil fell $1, or 1.3%, to $73.69.
All told, energy stocks fell the most among companies in the S&P 500 index, 2.1%. The sector is down 8.8% this year. That's on top of a loss of 24% for 2015.
Consumer staples stocks led the risers pack, adding about 1%. Macy's notched the biggest gain in the index, adding $2.93, or 8.2%, to $38.82.
HCA Holdings also rose after the hospital operator raised its profit forecast. The stock added $3.56, or 5.5% to $67.83.
European markets were down. Germany's DAX slipped 0.2%, while the CAC-40 in France lost 0.5%. The FTSE 100 index of leading British shares slid 0.7%.
In Asia, Chinese stocks sank again after a rebound Friday that analysts suggested was due to buying from a group of state entities dubbed the "National Team." The Shanghai Composite Index fell 5.3% and Hong Kong's Hang Seng sank 2.8%. Sydney's S&P/ASX 200 lost 1.2%, while Seoul's Kospi fell 1.2%. Tokyo's markets were closed for a holiday.
In metals trading, gold fell $1.70 to $1,096.20 an ounce, while silver fell 5 cents to $13.86 an ounce. Copper slipped 5 cents, or 2.4%, to $1.97 a pound.
Bond prices fell. The yield on the 10-year Treasury note rose to 2.18% from 2.12% late Friday.