Stocks rallied on Thursday, with the Dow industrials piercing the key 9,000 mark, as investors viewed strong quarterly results from 3M & Co and other companies, plus improving home sales data as signs the economy is stabilizing.

The market extended its early gains after data showed U.S. existing home sales rose in June -- the first time since 2004 that this measure has risen three months in a row. The Dow Jones U.S. home construction index <.DJUSHB> jumped 5.5 percent.

Results from bellwethers, including AT&T Inc on Thursday and eBay Inc a day earlier, ignited a rally that drove the S&P 500 index to its highest level in 2009. The Dow industrials rose above 9,000 points for the first time since January and the Nasdaq was on track for its 12th straight day of gains.

The economy does look like it's gradually recovering after a very deep recession. Consistent with the macroeconomic data, we are seeing evidence of a recovery in some corporate earnings results ... (though) part of the improvement is coming in the form of lower costs, said Zach Pandl, economist at Nomura Securities International in New York.

We're slowly turning the corner and it looks like the equity market is responding to that.

The Dow Jones industrial average <.DJI> jumped 171.48 points, or 1.93 percent, to 9,052.74. The Standard & Poor's 500 Index <.SPX> rose 21.12 points, or 2.21 percent, to 975.19. The Nasdaq Composite Index <.IXIC> gained 42.80 points, or 2.22 percent, to 1,969.18.

3M's stock rose 5.7 percent to $68.36 and contributed the most to the Dow's gain, after the diversified manufacturer handily beat Wall Street's profit expectations and lifted its revenue outlook for 2009.

Blue-chip AT&T's stock shot up 3.8 percent to $25.78 after it reported a smaller-than-expected drop in quarterly profit as strong sales of Apple Inc's iPhone helped increase wireless subscriber growth.

Among the Nasdaq's major advancer, eBay's stock surged 10.8 percent to $21.55. The online marketplace's results, released late on Wednesday, beat Wall Street's expectations.

Bristol-Myers Squibb Co shares gained 1.8 percent to $20.65 on the New York Stock Exchange after it reported second-quarter earnings above Wall Street's view and raised its full-year 2009 earnings forecast. Late on Wednesday, Bristol-Myers Squibb said it will buy biotechnology company Medarex Inc . At midday on Thursday, Medarex shares soared almost 90 percent to $15.87 on Nasdaq.

Only two of the 30 Dow components were trading lower at midday, with the decliners led by McDonald's Corp , down 3.7 percent to $56.62. Earlier in the day, McDonald's, the world's largest hamburger chain, reported lower quarterly profit and lower sales compared with a year ago.

Shares of Moody's Corp fell 2.8 percent to $25.79 after hitting an intraday low of $23.70 earlier, following news that Warren Buffett's Berkshire Hathaway Inc reduced its stake in the credit ratings provider.

Earlier on Thursday, U.S. government data showed claims for jobless benefits rose last week, roughly in line with expectations, while continuing claims declined.

Other companies expected to report quarterly earnings on Thursday include Amazon.com Inc , American Express Co and Microsoft Corp .

(Editing by Jan Paschal)