Shipping containers lie stacked on a ship docked at the Port Newark Container Terminal, Newark, New Jersey.

The U.S. trade deficit rose to a five-month high in May as the politically sensitive imbalances with China and Mexico widened.

The Commerce Department says the gap between the goods and services the U.S. sells and what it buys from foreign countries rose 8.4% to $55.5 billion in May, the highest since December. Exports increased 2% to $210.6 billion on rising shipments of soybeans, aircraft and cars. But imports climbed more — 3.3% to $266.2 billion — on an increase in crude oil and cellphones.

The deficit in the trade of goods with Mexico rose 18.1% to a record $9.6 billion. The goods gap with China widened 12.2% to $30.2 billion.

President Donald Trump sees America's trade deficits as a sign of weakness but hasn't been able to reduce them.