The S&P 500 turned positive for the year and closed out its third week of gains in four on Friday as equities extended their rally after a string of unexpectedly strong economic data.

The benchmark index has gained nearly 5 percent over its run of four straight winning days, putting it slightly higher for the year while volume continued to be seasonally light.

Investors cited recent improvement in U.S. economic data and seasonal factors behind the move, while a deal to extend the payroll-tax cut for two months added to the enthusiasm.

New U.S. single-family home sales rose to a seven-month high in November and the supply of houses on the market was the lowest in 5-1/2 years, giving hope for a recovery in the sector.

The day's big gainers included consumer discretionary <.GSPD> and information technology <.GSPT> stocks, both up 1.1 percent. Utilities <.GSPU>, considered a defensive play, were the day's relatively weakest group, up 0.7 percent.

The data have been improving, and that's leading to an improvement in investor sentiment, which is contributing to the more confident tone in the market, said Lawrence Glazer, managing partner at Mayflower Advisors in Boston.

Also, there's something psychologically significant in our turning higher for the year.

The S&P 500 edged above its 200-day moving average, a level that has proved difficult to maintain after plummeting below it in August. However, low holiday-season volume means investors are wary of the move.

The U.S. Congress approved a two-month extension of a payroll-tax cut for 160 million workers that otherwise would have expired on December 31. The resolution, if only temporary, removes a market headwind that investors said could have hit growth next year.

The Dow Jones industrial average <.DJI> shot up 124.35 points, or 1.02 percent, to 12,294 at the close. The Standard & Poor's 500 Index <.SPX> rose 11.33 points, or 0.90 percent, to 1,265.33. The Nasdaq Composite Index <.IXIC> gained 19.19 points, or 0.74 percent, to end at 2,618.64.

For the week, the Dow gained 3.6 percent, the S&P 500 climbed 3.7 percent, and the Nasdaq advanced 2.5 percent.

Volume was light ahead of the extended Christmas holiday weekend, which could spark exaggerated market swings next week. The New York Stock Exchange observed normal trading hours, but the bond market closed early, at 2:00 p.m. EST.

Brian Battle, a trader at Performance Trust Capital Partners in Chicago, warned about reading too much into the market's recent run. He said he was cautious heading into the new year, with Europe's debt crisis unresolved, growth still weak, and a U.S. presidential election looming. Financials <.GSPF>, the S&P 500's worst-performing sector this year, could continue to face amplified volatility.

We should all be careful not to deem it as the end, he said. We might take it all back in January.

SunPower Corp jumped 2.6 percent to $6 after the solar panels maker reached a deal to acquire rival Tenesol, a unit of France's Total SA . At the same time, Total is buying 18.6 million SunPower shares, raising its stake to about 66 percent.

Shares of Rambus Inc jumped 12.2 percent to $8.21. The company signed a patent-licensing deal with Broadcom Inc , resolving all previous claims related to its technology.

WPX Energy Inc will replace Compuware Corp in the S&P 500 index, with Compuware replacing Exterran Holdings Inc in the S&P MidCap 400 index, Standard and Poor's said.

Exterran will replace Skyline Corp in the S&P SmallCap 600 index. The changes are effective at the close of trading on Friday, December 30.

Compuware fell 0.2 percent to $8.31, Exterran slid 3 percent to $9.25, and Skyline dropped 6 percent to $4.41.

More than two-thirds of stocks traded on the New York Stock Exchanged closed in positive territory, while about 51 percent of Nasdaq-listed stocks closed higher.

(Reporting By Ryan Vlastelica; Editing by Jan Paschal)