Canada's merchandise trade deficit with the world shrank to $114 million in July, the smallest since a surplus in December 2016, as its trade surplus with the United States grew to the biggest in a decade, Statistics Canada reported Wednesday.

The federal agency reported that merchandise exports to the United States rose 3.3 per cent in July to $38.4 billion, while imports of American goods edged down 0.1 per cent to $33.1 billion in July.

As a result, Canada's merchandise trade surplus with the United States widened to $5.3 billion in July, from $4.1 billion in June — the biggest monthly trade surplus with its largest trading partner since October 2008.

Canada's surplus with the United States was offset by a $5.5 billion trade deficit with other countries, up from $4.8 billion in June.

The total value of Canada's exports to all countries rose 0.8 per cent to a record $51.3 billion, mainly because of higher crude oil prices, while the value of imports from all countries declined 0.4 per cent to $51.4 billion due to fewer aircraft imports, Statistics Canada said.

The overall trade deficit in July fell sharply from $743 million in June, a figure that was revised from $626 million in the previous report.

Several analysts said they had expected July's trade deficit would rise to about $1 billion and noted trade volumes reported by Statistics Canada on Wednesday were down overall — with exports falling 0.8 per cent and imports dropping 1.1 per cent.

They attributed most of the positive gains to higher energy prices.

"Overall, the rise in export prices masks what was actually a disappointing month for outbound shipments. Moreover, oil prices have since levelled off and other commodity prices have also softened," CIBC economist Royce Mendes wrote in a commentary.

"In spite of the narrower deficit, there's little reason then, to change our call for growth to slow in the third quarter."

A short time after the Statistics Canada report, the central bank announced its key interest rate will remain unchanged at 1.5 per cent, where it has been since July 11. Many economists have said the rate will likely be increased in October.

The trade report came as Canadian and U.S. negotiators resumed talks in Washington, D.C., following a four-day break from last week's intense efforts to reach agreement on revising the North American Free Trade Agreement.

President Donald Trump has claimed that the United States needs to eliminate large trade deficits with Canada, but a report from the U.S. Trade Representative says a 2017 deficit in goods (US$17.1 billion) was outweighed by a US$25 billion surplus in services sold to Canada.

Statistics Canada noted that July was the first month that Canada charged retaliatory tariffs on imported American steel and aluminum and the second month of U.S. tariffs on Canadian steel and aluminum.

The agency said that, on a seasonally adjusted basis, there was a 16.4 per cent increase in Canadian exports of steel subject to the U.S. duty imposed by President Donald Trump, following a 36.3 per cent decline in June.

Exports of Canadian aluminum subject to Trump's tariffs were down 2.0 per cent in July, on top of a 4.7 per cent decline in June.

Canada's imports of U.S. steel products subject to a 25 per cent tariff fell 39.6 per cent in July, on a seasonally adjusted basis, following a 32.7 per cent increase in June.

Canada's imports of U.S. aluminum that are subject to a 10 per cent retaliatory tariff were down 5.2 per cent and imports of other U.S. products subject to the 10 per cent tariff fell 22 per cent in July.

RBC economist Nathan Janzen noted that monthly data is volatile, so a few months doesn't make a trend "and risks around Canada's trade relationship with the U.S. remain."

"It could also be, though, that Canadian exports are finally starting to get at least a modest lift from stronger global trade flows and an improved U.S. industrial sector."