WASHINGTON - The nation's economy snapped out of a sluggish spell in the fourth quarter of last year and grew at a faster-than-expected 3.5 percent pace as consumers ratcheted up spending despite a painful housing slump.

The fresh snapshot of business activity, released yesterday by the Commerce Department, underscored the resilience of the economy; it has managed to keep growing despite the ill effects of the residential real estate bust and an ailing automotive sector.

The economy's performance in the October-to-December quarter, which followed two quarters of rather listless activity, exceeded analysts' forecasts for a 3 percent growth rate.

The economy opened 2006 on a strong note, growing at a 5.6 percent annual rate, but growth slowed to a 2.6 percent pace in the second quarter and a 2 percent pace in the third quarter.

For all of 2006, the economy, as measured by the gross domestic product, increased 3.4 percent. That was an improvement from a 3.2 percent showing in 2005 and was the best performance in two years.

GDP measures the value of all goods and services produced within the United States and is the best barometer of the country's economic standing.

The GDP report showed that consumer spending, a major factor behind the overall economic rebound, grew at a 4.4 percent annual rate, up from a 2.8 percent pace in the third quarter and the strongest since the opening quarter of 2006.

An improvement in the trade picture helped by stronger U.S. export growth also was a factor in the overall GDP boost.

More brisk government spending also helped. Government spending increased at a 3.7 percent pace in the final quarter, up from a 1.7 percent growth rate in the third quarter.

But investment in home building in the fourth quarter fell at a rate of 19.2 percent, worse than the 18.7 percent drop in the prior quarter. Both were the worst drops in 15 years.

In the troubled automotive sector, a pullback in car and truck production shaved 1.17 percentage points off fourth-quarter GDP.