Canada unexpectedly recorded a C$638 million ($461 million) trade surplus in June as an expanded crude oil pipeline and surging global demand for gold drove exports higher.

Economists in a Bloomberg survey had expected the country to record a trade deficit for the fourth month in a row, with a median estimate of C$2.04 billion. Statistics Canada noted in Tuesday’s release the size of the surplus was “close to the typical bounds of monthly revisions,” having revised the previous month’s trade balance upward by about C$320 million.

Exports rose 5.5% overall in June, outpacing a 1.9% rise in imports.

The reporty was released at the same time as US data that showed the country’s trade defict narrowed in June for the first time in three months. Canadian government two-year bond yields rose about three basis points on the day to 3.213%, while the loonie fell about 0.1% to C$1.384 per US dollar as of 8:45 a.m. in Ottawa.  

The rise in exports captures the impact of the Trans Mountain pipeline’s expansion, which began commercial operations in May. Prime Minister Justin Trudeau’s government spent billions to complete the near-tripling in capacity of a line that runs from Alberta’s oil sands to a Vancouver-area port.

Exports of energy products were up 11.7% in June, led by higher exports of crude oil. While crude oil prices rose in June, volumes were the largest contributor to the increase, driven largely by higher shipments to Asian countries. 

Strong international appetites for gold also pushed up Canadian exports, with metals and non-metallic mineral deliveries up 11.8% in June following a 7.3% decline in May. Statistics Canada noted that in the first half of the year, large monthly fluctuations were observed in export values of unwrought gold due in part to geopolitical turmoil. In June, gold exports to the UK rose considerably, it said.

June’s rise in imports points to resilience in consumer demand, with passenger vehicles and consumer goods driving the gain. Imports of passenger cars and light trucks rose 8.2% to a record C$6.8 billion in June, a fourth increase in five months. The growth occurred amid a recovery from production disruptions and delayed deliveries in the United States in late 2023 and early 2024, Statistics Canada said.

In volume terms, Canada’s exports rose 3.8% in June while imports increased 1.3%. The country’s trade surplus with the US widened for a third consecutive month, to C$9.4 billion from C$8.8 billion.