The U.S. trade deficit declined slightly in July as record exports of farm goods, autos and other products offset a big jump in foreign oil prices. The deficit with China hit the second-highest level ever, reflecting strong demand for Chinese-made goods despite a string of high-profile recalls.

The Commerce Department reported Tuesday that the trade deficit edged down 0.3 percent in July to $59.2 billion, compared with $59.4 billion the month before.

The decline was better than the slight increase many analysts had expected, but Ian Shepherdson, chief economist at High Frequency Economics, noted that the deficits for the past two months were revised higher.

So far this year, the deficit is running at an annual rate of $711 billion, down from $758.5 billion in 2006.

Economists believe the trade balance will finally shrink this year after setting five consecutive records as American exporters benefit from strong economic growth in many countries overseas and a weaker dollar against many currencies. That makes U.S. products cheaper on foreign markets and imports more expensive for American consumers.

The improvements in the trade deficit this year have not satisfied critics of President Bush's trade policies, who contend that this administration has left American workers vulnerable to unfair competition from low-wage countries such as China. These critics say the soaring deficits have contributed to the loss of more than 3 million manufacturing jobs since 2000.

For July, U.S. exports rose to 2.7 percent to an all-time high of $137.7 billion as sales of American farm goods, autos and auto parts and U.S.-made capital goods all set record highs.

Imports also rose to a record in July, climbing 1.8 percent to $196.9 billion. This increase was led by a 2.3 percent jump in petroleum imports, which hit $27.2 billion, the highest level in 11 months. The average price of a barrel of crude oil jumped to $65.56, the second-highest level in history. The record, according to Commerce Department measurements, was a $66.13 per barrel average in August 2006.

The boom in exports is helping cushion the U.S. economy from the adverse effects of the worst downturn in housing in 16 years and a serious credit crunch stemming from growing losses in subprime mortgages. Without continued export gains, some analysts worry that the country could be pushed into a recession.

America's deficit with China jumped 12.5 percent in July to $23.8 billion, the second-highest level on record, surpassed only by a $24.4 billion imbalance last October. So far this year, the deficit with China is running at an annual rate of $242 billion, putting the country on track to surpass last year's record deficit with China of $233 billion, the highest ever recorded with a single country.

The July imbalance reflected a 19 percent plunge in exports to China, as sales of commercial airplanes fell, and a 5.6 percent jump in imports, including higher shipments of cell phones, toys and clothing.

The rise in imports is occurring despite a number of high-profile recalls this year of unsafe products including tires, toothpaste, pet food ingredients and millions of toys recalled by toy giant Mattel because of such problems as lead paint and tiny magnets.

A presidential panel said Monday that the country's import-safety system has not kept pace with the huge increase in imports and recommended that federal agencies do a better job of coordinating oversight of imports.

Members of Congress have used the recalls of Chinese products to step up pressure to pass legislation that would punish China for what critics contend are unfair trade practices such as keeping the Chinese currency unfairly low against the dollar, which boosts the competitiveness of Chinese goods.

The Bush administration, led by Treasury Secretary Henry Paulson, has opposed these measures warning that they could lead to a protectionist backlash by the Chinese against U.S. exports.

After China, the United States recorded big deficits in July with Japan, an imbalance of $8 billion; Canada, a deficit of $5.7 billion, and Mexico, a deficit of $5.6 billion. The deficit with the European Union was $13 billion in July.