Stocks fell on Thursday, interrupting a recent rally, as investors booked profits after weaker-than-expected housing data.

Housing-related stocks were among the top decliners after data showed sales of new single-family homes fell for the first time in four months in December. The data followed Wednesday's soft pending home sales report and dented optimism that the housing market may have reached a bottom.

With the S&P 500 up nearly 5 percent for the year, analysts said the market was due for a pullback. Wall Street has advanced in recent weeks as U.S. data raised expectations the economic recovery was picking up steam.

This market is tired and overbought, and we're seeing the results of that today, said Larry McMillan, president of McMillan Analysis Corp.

After yet another knee-jerk rally on moderately positive economic news, the buyers are out of gas. It will be interesting to see if there is finally a day when the selling persists through the close.

Stocks began higher, helped by the Federal Reserve's vow on Wednesday to keep interest rates near zero at least until the end of 2014. Investors bet more money would be driven into risky assets.

Toll Brothers Inc lost 4.2 percent to $22.24. The PHLX housing sector index <.HGX> declined 1.3 percent. Banks, which stand to benefit from a recovery in housing, also fell. The KBW Bank index <.BKX> dropped 2.3 percent. SunTrust Banks Inc shed 5.5 percent to $20.43 after Deutsche Bank lowered its rating on the stock.

The Dow Jones industrial average <.DJI> was down 24.15 points, or 0.19 percent, at 12,732.81. The Standard & Poor's 500 Index <.SPX> was down 8.37 points, or 0.63 percent, at 1,317.68. The Nasdaq Composite Index <.IXIC> was down 15.71 points, or 0.56 percent, at 2,802.60.

Stocks also rose at the start after data showed orders for durable manufactured goods rose more than expected in December, while unemployment benefit claims last week rose only moderately.

The Dow's losses were limited as Caterpillar Inc rose 2.1 percent to $111.34. The manufacturer posted a jump in quarterly earnings that far exceeded Wall Street expectations on increased global demand for construction machinery and mining equipment.

3M Co , a conglomerate with operations throughout the economy also supported the Dow after it reported higher-than-expected quarterly earnings as demand from industrial and transport markets offset weak sales to makers of consumer electronics. The shares rose 1.2 percent to $87.58.

This is one of the busiest weeks of earnings season, with 117 S&P companies expected to report. According to Thomson Reuters data, 59 percent of the 152 companies in the S&P 500 that have reported earnings beat analysts' forecasts, down from the 70 percent beat rate in recent quarters at this stage.

AT&T Inc posted a $6.7 billion quarterly loss on a break-up fee for its failed T-Mobile USA merger and a pension-related charge on top of costly subsidies for smartphones. The shares fell 2.5 percent to $29.45.

Amgen Inc's shares fell 1.7 percent to $68.07 and weighed on the Nasdaq after the world's largest biotechnology company said it would pay more than $1 billion to buy Micromet Inc , a deal that would give it access to the company's novel cancer treatment technology.

Micromet's shares jumped 32.1 percent to $10.94 and were the most heavily traded on Nasdaq.

(Reporting By Angela Moon; additional reporting by Doris Frankel; Editing by Kenneth Barry)