Canada posted a surprise trade surplus of Can$638 million (US$461 million) in June, led by a surge in oil and gold exports, the government statistical agency said Tuesday.

Gold demand jumped recently as a hedge against global political and economic uncertainty, while the opening of a new pipeline from Alberta to Canada's Pacific coast resulted in increased shipments to Asian countries.

Combined, gold and oil accounted for three-quarters of Canada's increased exports in June, which rose 5.5 percent to Can$66.6 billion.

Imports increased 1.9 percent to Can$66.0 billion, with a record number of passenger cars and light trucks brought into the country, marking a recovery from production disruptions and delayed deliveries in late 2023 and early 2024.

Imports of pharmaceutical products were also up in June.

These increases were partly offset by lower imports of gold for refining and copper ores and concentrates.

The second quarter ended on a high, with both imports and exports up slightly, following mixed results in the first three months of 2024.

Trade with the United States, Canada's largest trading partner widened in June for a third consecutive month to Can$9.4 billion.