Specialist Michael Gagliano, foreground center, works with traders at his post on the floor of the New York Stock Exchange, Wednesday.

For much of Wednesday, the U.S. stock market appeared to be headed for its third decline in three days.

By late afternoon, the market began to slowly pare its losses as investors bought up oil refiners, mining companies and technology stocks.

The push was enough to nudge the Standard & Poor’s 500 index into the green by half a point. The tech-heavy Nasdaq composite also finished higher.

The S&P 500 index added 0.57 points, or 0.03 percent, to close at 1,868.20. The Dow Jones industrial average lost 11.17 points, or 0.1 percent, to 16,340.08.

The Nasdaq composite rebounded in the early afternoon, gaining 16.14 points, or 0.4 percent, to 4,323.33.

The three major U.S. stock indexes are still down for the week. Stocks had a strong finish last week, setting three record highs.

Investors have been worried this week about a sharp drop in China’s exports in February reported over the weekend, which raised concerns that the world’s second-largest economy is slowing. Since China is a big consumer of raw materials and energy, commodities such as copper and iron ore have dropped sharply. Copper has fallen to its lowest level since 2010, but recovered somewhat Wednesday.

A dearth of major U.S. economic news helped dampen trading Wednesday, leaving the market listless.

“When markets reach these kind of new highs very often they have to digest those gains, which is what they’re doing,” said Quincy Krosby, a market strategist with Prudential Financial. “They need to adjust the gains and then wait for the next catalyst to move higher.”

That could come Thursday, when new data on retail sales and weekly unemployment benefit applications are released. On Friday, a survey of consumer confidence should give traders a better sense of how Americans feel about the economy.

The state of China’s economy is sure to continue to be a focus, however.

“We’ve been seeing these periodic, occasional weak data points come out of China,” said Randy Frederick, managing director of trading and derivatives at the Schwab Center for Financial Research. “And each time that happens when our markets are at ... record highs, they’re going to be very sensitive to any sort of negative news and there’ll be days of profit-taking.”

While China growth concerns appeared to hurt oil prices Wednesday, it didn’t stop investors from buying up oil refiners.

Tesoro Corp. rose the most of any stock in the S&P 500 index, climbing $2.13, or 4.1 percent, to $54.50. Marathon Petroleum Corp., added $3.21, or 3.5 percent, to $94.50, while Valero Energy Corp., gained $1.62, or 3 percent, to $55.29.

Tech giants Google, Microsoft and Facebook also contributed to the day’s gains. Together they make up about 12 percent of the Nasdaq composite. Google rose $7.31, or 0.6 percent, to $1,207.30; Microsoft added 25 cents, or 0.7 percent, to $38.27 and Facebook climbed 78 cents, or 0.8 percent, to $70.88.