Sales at U.S. retailers unexpectedly fell in July from June, a government report showed on Thursday, casting a shadow over an anticipated rebound in consumer spending in the third quarter.

The Commerce Department said total retail sales edged down 0.1 percent from increasing a revised 0.8 percent in June. Sales in June were initially reported to have risen 0.6 percent.

Analysts polled by Reuters had forecast retail sales rising 0.7 percent in July, expecting a boost from the government's cash for clunkers program, which gives consumers cash to swap aging gas-guzzlers for new, more fuel efficient models.

Excluding motor vehicles and parts, sales fell 0.6 percent in July after rising 0.5 percent the prior month. Analysts had expected a 0.1 percent gain in sales excluding autos.

Gasoline station sales fell 2.1 percent in July, reflecting a retreat in gasoline prices during the month, after surging 6.3 percent in June. Excluding gasoline, retail sales nudged up 0.1 percent. Sales of building materials were down 2.1 percent in July after falling 0.6 percent in June.

(Reporting by Lucia Mutikani; Editing by Neil Stempleman)