WASHINGTON — America's trade deficit shot up in July to the highest level in 16 months as oil imports hit an all-time high, offsetting strong export growth. The deficit with China climbed to the second highest level on record.

The Commerce Department reported Thursday that the deficit rose by 5.7 percent to $62.2 billion in July, much worse than the $58 billion deficit that Wall Street expected. It pushed the gap between what America imports and what it sells abroad to the highest level since March 2007.

The trade deterioration reflected the fact that crude oil prices hit a record in July, pushing America's foreign oil bill to an all-time high of $51.4 billion, up 13.7 percent from June.

The big rise in oil prices, with the average barrel of imported crude jumping to a record $124.66, pushed overall imports up by 3.9 percent to a record $230.3 billion.

That increase offset another strong showing for U.S. exports which rose by 3.3 percent to a record $168.1 billion, reflecting big gains in overseas sales of commercial aircraft, computers and U.S.-made cars. Exports have been the major bright spot for the U.S. economy in a year when the country has been battered by a prolonged slump in housing, rising unemployment and a severe credit crunch.

The Bush administration points to the export gains as justification for its support of free trade. However, Democrats contend the administration's pursuit of free-trade agreements left U.S. workers exposed to unfair competition from low-wage countries with poor environmental records such as China.

They blame the loss of more than 3 million manufacturing jobs since Bush took office in part on the soaring trade deficits, employment losses that have hit hard in key presidential battleground states such as Michigan, Ohio and Pennsylvania.

Democratic presidential candidate Barack Obama has said he will renegotiate the North American Free Trade Agreement with Canada and Mexico to get greater protection for U.S. workers. Republican John McCain has accused Obama of seeking to erect protectionist barriers that will make America less competitive in the global economy.

In July, the politically sensitive deficit with China increased 16.1 percent to $24.9 billion, the second highest gap on record.

Critics contend the administration has not done enough to combat unfair Chinese trade practices such as the country's currency system, which U.S. manufacturers say keeps the Chinese yuan undervalued by as much as 40 percent against the American dollar. That makes Chinese goods cheaper for American consumers while making U.S. products more expensive in China.