A rise in U.S. consumer confidence to its highest in six months and a much bigger-than-expected contraction in the country's trade deficit pointed to a firmer economic recovery on Friday.

The boost in consumer confidence on the back of an improving jobs outlook was another indication consumers are willing to spend over the holidays while a rise in exports looks set to lift economic growth this quarter.

The data fits into a pattern of an economy that is gaining traction after a slowdown in the summer and is likely to intensify the debate over whether the Federal Reserve needs to keep stimulating the economy through asset purchases.

We are in the gradual recovery camp and are definitely on the upper side of that now, said Pierre Ellis, senior global economist at Decision Economics in New York. It adds to a growing number of economic indicators that are looking better than expected.

Consumer sentiment in December rose to its highest level since June and was at its third-highest since the start of 2008, according to a Thomson Reuters/University of Michigan survey. Government data showed U.S. exports in October rose a robust 3.2 percent while imports declined slightly.

U.S. stock indexes closed higher, with the S&P 500 at its highest level since the week Lehman Brothers collapsed in 2008. U.S. Treasury bond prices lost ground while the dollar gained.

The survey's preliminary December reading for consumer sentiment came in at 74.2, up from 71.6 in November. That was above the median forecast of 72.5 among economists polled by Reuters.

Consumers cited a more favorable jobs outlook, chiming with recent data pointing to some improvement in the labor market. But slow jobs growth and high unemployment is still one of the biggest impediments to the recovery.

Although the unemployment rate edged up to 9.8 percent in November, new claims for unemployment benefits fell more than expected last week and the four-week moving average slipped to a fresh two-year low.

Federal Reserve Chairman Ben Bernanke has hinted that the U.S. central bank may increase its current $600 billion bond purchasing program if unemployment continues to stay high.

The sentiment survey's barometer of current economic conditions rose to its highest since January 2008, just after the economic downturn began. The index for December came in at 85.7, up from 82.1 in November and above a forecast of 83.1.

Meanwhile, the U.S. trade deficit for October totaled $38.7 billion, down from a revised estimate of $44.6 billion for September. Analysts surveyed before the report had expected the deficit to narrow just slightly to about $43.60 billion.

Record exports to China and Mexico helped push the overall export tally to $158.7 billion, the highest since August 2008. Exports to the European Union and Japan also grew.

Despite record exports to China in October, the U.S. trade deficit with that country in the first 10 months of 2010 was $226.8 billion, up 20.3 percent from the year-earlier period.

The sharp rise is likely to keep China's trade and currency policies on the minds of U.S. lawmakers in 2011.

The smaller-than-expected trade deficit could boost estimates for U.S. fourth-quarter economic growth because it implies a larger share of U.S. demand is being met by domestic production.

This suggests that the economy is accelerating, said Neil Dutta, an economist at Bank of America Merrill Lynch in New York, raising his forecast for fourth-quarter economic growth to about 3.0 percent.

On an annual basis, the trade deficit has widened sharply this year and could surpass $500 billion when final figures for 2010 are available. Last year, in the midst of the global financial crisis which put a squeeze on world trade, the U.S. trade gap narrowed about 46 percent to $374.9 billion.

The United States posted a larger-than-expected budget deficit in November, the Treasury Department said, as President Barack Obama tries to sell a compromise made earlier in the week with Republicans on Capitol Hill over a two-year extension of tax cuts enacted by President George W. Bush.

The $150 billion shortfall in November was the 26th straight monthly deficit, the longest streak on record and the largest budget gap for any November.

Last week, a bold plan to slash the U.S. budget deficit fell short of winning the support needed to trigger legislative action in Congress, shifting the fiscal responsibility issue to the White House and lawmakers.

The grim budget outlook will be a major challenge for House Republicans, who have promised budget cuts when they officially take control of the lower House next month.

(Additional reporting by Corbett B. Daly in Washington; Editing by James Dalgleish)