WASHINGTON — The U.S. trade deficit surged in July to $63.6 billion, the highest level in 12 years, as imports jumped by a record amount.

The Commerce Department reported that the July deficit, the gap between what America buys and what it sells to foreigners, was 18.9% higher than the June deficit of $53.5 billion. It was the largest monthly deficit since July 2008 during the 2007-2009 recession.

The July deficit increase was driven by a record 10.9% increase in imports which rose to $231.7 billion. Exports were also up but by a smaller 8.1% to $168.1 billion.

When Donald Trump campaigned for president in 2016 he pledged to sharply lower the country's large trade deficits, especially with China, which for years has been the country with the largest trade surplus with the United States.

But despite a number of high-profile trade battles and a renegotiation of the North American Free Trade Agreement with Canada and Mexico, America's trade deficits have remained stubbornly high.

For July, the deficit with China in goods totaled $31.6 billion, an 11.5% increase from the June imbalance.

The goods deficit with Mexico hit a record high of $10.6 in July. Trump has claimed the new free trade deal he has negotiated with Mexico and Canada will be a boon for American workers and businesses.

The United States ran a deficit in goods trade of $80.1 billion in July, the highest on record. The U.S. surplus in services, such as banking and insurance, declined to $17.4 billion, the smallest services surplus since August 2012 and a reflection in part of the decline in airline travel during the pandemic.

The increase in the overall deficit in July was bigger than economists had been expecting.

Michael Pearce, senior U.S. economist at Capital Economics, said he expected the rising deficit, which subtracts from U.S. growth, would cut the gross domestic product for the July-September quarter by about one percentage-point. But he still forecast GDP would rebound at an annual rate of 30% in the third quarter after having fallen at a rate of 31.7% in the second quarter.

The pandemic has seriously disrupted global supply chains this year and economists said while it was good news to see trade rebounding now, the gains are coming from very low levels.

"A strong and sustained rebound in trade flows is uncertain given a still weak global growth and demand backdrop," said Rubeela Farooqi, chief U.S. economist at High Frequency Economics.