Stocks gained on Tuesday but were off session highs, after strong housing and consumer confidence data and Ben Bernanke's renomination as Federal Reserve chairman cheered investors.

Financials were among the top gainers, with shares of JPMorgan Chase & Co up 1.8 percent, and Regions Financial Corp up 2.5 percent. The S&P financial sector index <.GSPF> rose 1 percent.

Consumer confidence increased more than expected in August, the Conference Board said, while the S&P/Case-Shiller home price index rose in June for a second straight month.

A rebound in home prices as well as stronger consumer spending are seen as critical for the economy to bounce back from its worst recession in decades.

Overall, stocks have had a nice rally. They're sporting new recovery highs and are trading 53 percent above their lows, said Steve Goldman, market strategist at Weeden & Co in Greenwich, Connecticut.

In another time, this data maybe would've helped, but now it's not helping so much since we've had such gains over the past four or five weeks.

U.S. President Barack Obama nominated Bernanke for a second term as Fed chairman, saying he approached a financial system on the verge of collapse with calm and wisdom.

The Dow Jones industrial average <.DJI> rose 59.33 points, or 0.62 percent, to 9,568.61. The Standard & Poor's 500 Index <.SPX> added 6.12 points, or 0.60 percent, to 1,031.69. The Nasdaq Composite Index <.IXIC> gained 11.11 points, or 0.55 percent, to 2,029.09.

The three major indexes rose more than 1 percent earlier in the session.

A 1 percent slide in crude oil futures hurt energy shares, sending the S&P energy index <.GSPE> down 0.4 percent.

(Reporting by Rodrigo Campos; additional reporting by Ryan Vlastelica; editing by Jeffrey Benkoe)