Rising exports of motor vehicles, aircraft and energy products helped Canada post a C$762 million trade surplus in goods in May, Statistics Canada reported.
Analysts had forecast a shortfall of C$1.50 billion, while April's deficit was revised slightly wider to C$1.08 billion.
The trade data gave the loonie a small lift in "very quiet trading" ahead of the US Independence Day holiday on Thursday, said Eric Theoret, a currency strategist at Scotiabank.
The price of oil, one of Canada's major exports, rebounded after a steep fall in the previous session when a decision by OPEC and its allies to extend output cuts failed to counter investors' concerns about the slowing global economy. US crude oil futures settled 1.9pc higher at $57.34 a barrel.
At 3:41 p.m. (1941 GMT), the Canadian dollar was trading 0.3pc higher at 1.3064 to the greenback, or 76.55 US cents. The currency, which last Friday touched nearly an eight-month high at 1.3060, traded in a range of 1.3062 to 1.3119.
The loonie has benefited in recent weeks from data showing a recovery in the domestic economy, which could keep the Bank of Canada on hold over the coming months even if the Federal Reserve cuts interest rates as the market expects. Money markets see about a 30pc chance of a Bank of Canada interest rate cut this year.
A clue to the direction of Canadian interest rates could come from Canada's jobs report for June, which is due on Friday.
Canadian government bond prices were mixed across a flatter yield curve, with the two-year down 2 Canadian cents to yield 1.493pc and the 10-year rising 13 Canadian cents to yield 1.453pc.
The gap between Canada's two-year yield and its US equivalent narrowed by 1.5 basis points to a spread of 26.8 basis points in favor of the US bond, its narrowest gap since February last year.