Imports of goods decreased $1.9 billion and imports of services increased $0.1 billion.
Exports of US goods and serviced climbed 1.9 percent to $186.3 billion in July, but not all global regions were trending in the same direction.
Imports declined 0.1% on the month with volumes down 1.2% with total imports declining 2.6% over the year. Goods were $124.1 billion in July, up from $120.6 billion, while services were $62.3 billion in July, down less than $0.1 billion from June.
In a report for the G20 summit in China beginning Sunday, The International Monetary Fund warned that lack of action to boost growth by the world's major economies was resulting in sluggish trade.
The gap shrank 11.6 percent to $39.5 billion from $44.7 billion in the prior month, Commerce Department figures showed Friday in Washington.
United States exports got a particular boost from a US$3.6 billion surge in soybean exports in July, helped by a rebound in prices after last year's slump. A strong dollar makes US goods and services more expensive for overseas buyers and makes imports cheaper for USA consumers. But economists believe the drag from the dollar's rise may be lessening. On that basis exports advanced 3.7 percent and import volumes fell 1.2 percent, Statistics Canada said.
Trump has said he would exit from the North American Free Trade Agreement with Canada and Mexico if it is not improved and will kill the pending Trans-Pacific Partnership trade agreement between America and 11 Pacific Rim nations.
While oil prices plunged at the beginning of the year, they have been rebounding more recently.
Imports of crude oil fell in July as the per-barrel price rose for the fifth straight month to its highest level since September 2015.
The fall in imports was led by a drop in imported consumer goods, especially pharmaceutical preparations.