(Reuters) - U.S. stocks staged a late-day rally on Wednesday as an 8-percent jump in oil prices lifted beaten-down energy shares and financials rebounded.

Traders work on the floor of the New York Stock Exchange January 29, 2016. REUTERS/Brendan McDermid

The Nasdaq stayed weaker but ended well off the day’s lows.

Oil prices LCOc1CLc1 snapped a two-day rout as investors took advantage of a weaker U.S. dollar. Comments by Russia's foreign minister reignited hopes of a deal among oil producers to trim output. The energy index .SPNY jumped 4 percent.

“What (markets) are keying off of is the move in commodities and in the dollar,” said Walter Todd, chief investment officer at Greenwood Capital Associates in Greenwood, South Carolina. “That is driving the rotation in the equity market out of momentum names into commodity-based names.”

Alphabet GOOGL.O shares tumbled 4 percent to $749.38 and the company moved back below Apple AAPL.O in market capitalization. Apple, the world's most valuable company, rose 2 percent at $96.35.

Alphabet’s selloff may be a combination of broad-based weakness in tech stocks that are trading at high valuations and the departure of Amit Singhal as senior vice president of the company’s search business, said Kevin Kelly, chief investment officer for Recon Capital Partners.

“That was a little surprising, especially this close after earnings,” he said, referring to Singhal’s departure.

The Dow Jones industrial average .DJI ended up 183.12 points, or 1.13 percent, to 16,336.66, the S&P 500 .SPX gained 9.5 points, or 0.5 percent, to 1,912.53 and the Nasdaq Composite .IXIC dropped 12.71 points, or 0.28 percent, to 4,504.24.

Other high-flying tech names that fell on Wednesday included Amazon AMZN.O, down 3.8 percent at $531.07.

The dollar's .DXY decline may have eased worries about the impact of dollar strength on U.S. multinationals' earnings. Shares of 3M Co. MMM.N, up 3.1 percent at $152.52, led gains in the Dow.

The S&P materials .SPLRCM was up 3.3 percent, the day's second-best performing sector. The S&P financial index .SPSY ended down just 0.1 percent after hitting its lowest in more than two years.

Stocks’ late-day rally reversed sharp losses in morning trading. U.S. data showed the economy’s service sector expanded at a slower-than-expected rate, raising concerns that weakness in manufacturing was spreading to other areas of the economy.

In other economic news, ADP data showed private employers added more jobs than expected in January. The data comes ahead of the government’s more comprehensive employment report on Friday.

Tepid U.S. growth, falling oil prices, and fears regarding a China-led global slowdown have combined to drive stocks down sharply since the start of the year.

After the bell, CBS Corp CBS.N said media mogul Sumner Redstone had resigned as executive chairman. Shares of Viacom Inc VIAB.O, where Redstone is also chairman, shot up 10.6 percent to $49.40. CBS shares also were up.

During the session, about 10.2 billion shares changed hands on U.S. exchanges, above the 9.2 billion daily average for the past 20 trading days, according to Thomson Reuters data.

Advancing issues outnumbered decliners on the NYSE 1,920 to 1,102; on the Nasdaq, 1,393 issues fell and 1,391 advanced. The S&P 500 posted 22 new 52-week highs and 56 new lows; the Nasdaq recorded 16 new highs and 236 new lows.