WASHINGTON - The U.S. trade deficit declined during the third quarter to the lowest level in two years, raising hopes that the country's trade troubles could be easing.

The Commerce Department reported yesterday that the current-account trade deficit fell 5.5 percent to $178.5 billion in the July-to-September quarter. That was a better-than-expected showing and the smallest current-account imbalance since a $173.4 billion deficit in the third quarter of 2005.

The current account is the most comprehensive measure of trade because it includes not only trade in products and services but also investment flows between countries.

The current-account deficit had set all-time highs for five consecutive years, but has declined for two consecutive quarters, prompting economists to predict that this year will see the deficit finally start to decline.

The improvement reflects in part the decline of the dollar against many other major currencies. A weaker dollar makes U.S. products cheaper in foreign markets while making foreign goods more expensive for U.S. consumers.

The deficit in goods shrank 2.2 percent to $199.7 billion in the third quarter as record levels of export sales helped offset a rising foreign-oil bill.

The surplus in services, items such as airline tickets and consulting fees, increased 3 percent to $26.5 billion. The surplus in investment income flows surged 61.5 percent to $20.5 billion. The only deterioration occurred in the category that includes foreign aid, which rose to $25.8 billion, up from $23.2 billion the previous quarter.

The decline in the current-account deficit left it at 5.1 percent of the country's total economic output, down from 5.5 percent from the second quarter. That was the lowest level in terms of GDP since the first quarter of 2004.

The U.S. trade deficit with China, however, is running at a higher rate than a year ago, putting it on track to surpass last year's record and setting off a backlash in Congress, where many lawmakers are demanding that the United States impose economic sanctions on Chinese goods.