Statistics Canada says booming exports produced a trade surplus of $24 million in March, compared with a $1.2-billion deficit in February.

The change came as merchandise exports increased 5.1% to $40.5 billion while imports rose just 1.7%, to $40.4 billion.

Export gains were recorded in all sectors in March, while the main contributors to higher imports were energy products and metal and non-metallic mineral products.

Exports to the United States rose 4.0% to $29.5 billion, while imports from the U.S. were up 2.0% to $25.6 billion, raising the trade surplus with that country to $3.8 billion from $3.2 billion in February.

Exports to countries other than the United States rose 7.9% to $11 billion, while imports from those countries rose 1.2%, to $14.8 billion. That cut the trade deficit with those markets to $3.8 billion from $4.4 billion in February.

Exports of energy products rose 3.9% to $9.1 billion in March, mainly because of a 24.8% increase in volumes of natural gas.