Stocks advanced on Thursday in a volatile session, erasing early losses as a rebound in commodity prices kept the market churning higher.

Analysts cited a confluence of factors for the rebound in riskier assets, including a bounce in the euro, a lackluster auction of long-term U.S. debt, and signals that the White House and Congressional Republicans were moving closer to an agreement on raising the national debt ceiling.

Commodities rose after U.S. data showed a decline in jobless benefit claims last week and a revision to retail sales data suggested consumer spending in the first quarter might have been stronger than initially thought.

What longer term investors have to be wary of here is that is very hot money. If it does come back in, it is not likely to stay for long and the fundamentals of supply and demand do matter, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

U.S. crude futures rose 1.5 percent after a drop of more than 1 percent and the S&P energy sector <.GSPE> added 0.4 percent, rebounding from a decline of more than 1 percent. The sector has tumbled more than 7 percent this month after it gained 16.3 percent in the first quarter to propel the benchmark S&P 500 higher by 5.4 percent.

Financial shares fell after Rochdale Securities banking analyst Dick Bove put a sell rating on Goldman Sachs Group and reduced the price target on the stock to $120 from $163, citing litigation worries.

Goldman shares slumped 3.7 percent to $142.42 as volume topped the 50-day moving average. Both the KBW bank index <.BKX> and the S&P financial sector <.GSPF> shed about 0.1 percent.

Cisco Systems Inc warned on Wednesday it would fare worse this quarter than Wall Street had forecast. The tech company laid out plans for global job cuts as it struggles to revive growth. Its shares fell 4.4 percent at $17.00 as the worst performer on the Nasdaq 100.

The Dow Jones industrial average <.DJI> gained 65.36 points, or 0.52 percent, to 12,695.39. The Standard & Poor's 500 Index <.SPX> gained 7.04 points, or 0.52 percent, to 1,349.12. The Nasdaq Composite Index <.IXIC> gained 16.48 points, or 0.58 percent, to 2,861.54.

The Reuters/Jefferies CRB index <.CRB>, a broad measure of commodity performance, rose 0.6 percent on Thursday but has lost more than 8 percent so far in May.

(Reporting by Chuck Mikolajczak; Editing by Padraic Cassidy)