Stocks rose on Thursday as better-than-expected data on home sales and employment lent support to the market after equities suffered their worst day in eight weeks in the previous session.

But trading was volatile as investors awaited a key vote on a bill to cut the U.S. deficit. A gridlock in talks over the country's debt ceiling and a possible downgrade of the United States' credit rating have weighed on global equities.

The S&P lost 2.6 percent for the week while the Dow fell 2.8 percent. The Nasdaq was off 2.7 percent.

After a 90 percent down day like yesterday and considering how intense the selling was, today's data is certainly lending support, said James Dailey, portfolio manager of TEAM Asset Strategy Fund in Harrisburg, Pennsylvania.

Part of the bounce today is also technical, (so) any kind of news from Washington could easily turn the market.

The Dow Jones industrial average <.DJI> was up 32.02 points, or 0.26 percent, at 12,334.57. The Standard & Poor's 500 Index <.SPX> was up 5.46 points, or 0.42 percent, at 1,310.35. The Nasdaq Composite Index <.IXIC> was up 19.76 points, or 0.71 percent, at 2,784.55.

Pending sales of existing U.S. homes unexpectedly rose 2.4 percent June from May and were up sharply from a year ago, a real estate trade group said on Thursday.

Further boosting optimism about the economy, new U.S. claims for jobless benefits fell more than expected last week, dropping below 400,000 for the first time since early April.

Exxon Mobil Corp , the world's largest publicly traded oil company, said higher oil prices contributed to a rise in its second-quarter profit, but results fell short of expectations. The stock fell 1.3 percent to $82.02.

A bill to cut the U.S. deficit faced an extremely nail-bitingly close vote in Congress on Thursday as the top Republican lawmaker sought to quell an internal revolt and push his plan to avoid a ruinous default.

Approval of a plan by House of Representatives Speaker John Boehner would break the inertia in Washington over a U.S. debt crisis that has spooked markets and raised the prospect that the government of the world's largest economy will run out of money to pay its bills in less than a week.

(Editing by Padraic Cassidy)