Bears transformed into bulls by the final hour of trading Thursday, thanks to a sudden pivot in oil prices. 

The S&P 500 was up 1.1%, the Dow Jones Industrial Average added 1.3%, and the Nasdaq gained 0.87%. Benchmark indexes had struggled for direction earlier in the session.

"The market is in a tug of war," Steve Chiavarone, associate portfolio manager at Federated Investors, told TheStreet. "There is a reasonable case to be made that markets should move much lower and there's a reasonable case to be made that markets should start to stabilize here and do better."

Oil was again the main driver of trading on Thursday, and its erratic moves highlighted how any direction could potentially be justified with available evidence. Crude started off the day in selloff mode after Citi economists predicted a looming global recession. That triggered panic among commodity traders already worried over a growing supply glut. 

"In our view, global growth is at a highly precarious point, after two to three years of relative calm," Citi economists wrote in a note. "The long-standing fragilities in the world economy relate to the structural and cyclical slowdowns in China and its unsustainable exchange-rate regime, the excessive level of debt across many countries and sectors and ongoing regional and geopolitical uncertainty."

Then, mid-afternoon, crude turned positive after the Organization of Petroleum Exporting Countries fueled hope over a production agreement. Reports indicated Venezuela, Russia, Saudi Arabia and Qatar had agreed to meet in March to further negotiate a production freeze. West Texas Intermediate gained 2.9% to $33.07 a barrel on Thursday.

TheStreet Recommends

Durable goods orders rebounded in January, suggesting that fears over a manufacturing slowdown in the U.S. may have been overblown. New orders for U.S. manufactured goods climbed 4.9%, well over the expected 2% growth. However, pressure in the sector remains. 

"While today's report breathes some life into the outlook for the troubled manufacturing sector as well as prospects for business spending, we are not out of the woods yet," Wells Fargo economists wrote in a note. "Core capital goods orders and shipments are both falling on a three-month annualized basis."

It was a busy day for earnings in the final leg of the reporting season. AB InBev (BUD) - Get Anheuser-Busch InBev SA/NV Sponsored ADR Report fell after missing profit estimates due to weaker market share in the U.S. The world's biggest brewer reported a 10% decline in overall sales.

Retailer Kohl's (KSS) - Get Kohl's Corporation (KSS) Report climbed on Thursday after beating estimates in its recent quarter and announcing a $600 million share buyback program. Fellow retail company Best Buy (BBY) - Get Best Buy Co., Inc. Report gained, despite issuing a disappointing outlook. The company also announced a 22% increase in its quarterly dividend and a new $1 billion stock buyback plan.

Restoration Hardware (RH) - Get RH (Restoration Hardware) Report slumped after fourth-quarter results came in well below estimates. Adjusted earnings of 99 cents a share missed estimates of $1.39, while revenue of $647.2 million fell short of forecasts of $711 million. (CRM) - Get, inc. Report climbed on a stronger outlook. The cloud-software company expects first-quarter earnings between 23 cents and 24 cents a share, above expectations of 21 cents.

HP (HPQ) - Get HP Inc. (HPQ) Report slid after its first earnings report since spinning off its cloud business into Hewlett Packard Enterprise (HPE) - Get Hewlett Packard Enterprise Co. (HPE) Report . The printer and PC company expects full-year earnings between $1.59 and $1.69 a share, potentially exceeding consensus of $1.60.