Sales at U.S. retailers rose more than expected in April, raising cautious optimism that a recent bounce in consumer spending can be sustained.

Total retail sales rose 0.4 percent following an upwardly revised 2.1 percent surge in March, the Commerce Department said on Friday. Sales in March were previously reported to have increased 1.9 percent.

Retail sales have now increased for seven straight months and in April were lifted by a surprise gain in motor vehicle receipts.

Analysts polled by Reuters had forecast retail sales rising 0.2 percent last month. Compared to April last year, sales were 8.8 percent higher.

This adds to a string of data we have received indicating that consumer spending is improving, said James Cox, managing partner at Harris Financial Group in Colonial Heights, Virginia.

U.S. stock futures trimmed losses on the report, while Treasury debt prices pared gains. The U.S. dollar trimmed losses against the yen.

Motor vehicle and parts purchases unexpectedly rose 0.5 percent after increasing 6.7 percent in March. Analysts had expected the government's dollar measure of auto sales to fall in April, after automakers reported a decline in unit sales.

Excluding autos, sales rose 0.4 percent last month after rising 1.2 percent in March. April's rise was in line with market expectations.

Households are now participating in the economy's recovery, encouraged by an improving labor market. Economic growth resumed in the second half of 2009 following the worst recession since the Great Depression and continued into the first quarter of this year.

Growth initially had been largely driven by businesses replenishing inventories, but consumer spending grew in the first quarter at its fastest pace in three years.

There were some areas of weakness in retail sales last month.

Core retail sales, which exclude autos, gasoline and building materials, fell 0.2 percent after increasing 0.7 percent in March. Core sales correspond most closely with the consumer spending component of the government's gross domestic product report.

Clothing and clothing accessories sales fell 1.0 percent, after surging the prior month because of an early Easter holiday and warm weather.

Sales at electronics and appliance stores slipped 0.4 percent, defying market expectations for a rise. Receipts at sporting goods, hobby and book stores fell 1.9 percent in April.

Building materials and garden equipment receipts, however, climbed 6.9 percent, while receipts at gasoline stations rose 0.5 percent.

(Reporting by Lucia Mutikani; Additional reporting by John Parry in New York; Editing by Andrea Ricci)