Solid earnings from several companies, including Dow components 3M , AT&T and McDonald's Corp lent credence to the idea that corporate profitability has stabilized.

After the closing bell, online retailer Amazon.com posted earnings above expectations and its shares shot up almost 15 percent to $107.38 in extended trading.

The market has been supported by consistent news of better- than-expected earnings and fairly good guidance, according to Robert Lutts, chief investment officer of Cabot Money Management in Salem, Massachusetts.

Regional banks came out with OK results. They talked about deterioration in assets definitely at a slower pace and there were indications some parts of the loan books were stabilizing and improving, Lutts said.

Shares of J Crew Group Inc soared 15.2 percent to $43.49 after the clothing retailer raised its outlook for the third and fourth quarters, citing stronger-than-expected sales and margin trends expected to last throughout the year.

J Crew led retailers higher, with the S&P retail index up 1.7 percent.

The New York Times Co beat quarterly revenue and profit forecasts because of cost cuts and higher newspaper prices even as advertising sales fell, driving its shares up 22.5 percent to $10.72.

Shares of home builders also ranked among the top gainers, with the Dow Jones U.S. home construction index up 5.3 percent. Shares of KB Home jumped 7.5 percent to $16.17 and Pulte Homes gained 6.5 percent to $10.44.

Housing and Urban Development Secretary Shaun Donovan said earlier this week the administration would decide in coming weeks whether it backs an extension of the current tax credit for first-time home buyers, set to expire on November 30.

Volume was moderate on the New York Stock Exchange, with about 1.32 billion shares changing hands, below last year's estimated daily average of 1.49 billion. On the Nasdaq, about 2.30 billion shares traded, slightly above last year's daily average of 2.28 billion.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of about 2 to 1, while on the Nasdaq, nearly eight stocks rose for every five that fell.