OTTAWA—Canada’s trade deficit with the rest of the world swelled to a record level in June and missed expectations by a wide margin, capping off the worst quarterly performance for exports since the height of the global financial crisis in 2009.

Canada’s trade deficit widened to 3.63 billion Canadian dollars ($2.79 billion) in June, Statistics Canada said Friday. Economists anticipated a C$2.8 billion deficit, according to Royal Bank of Canada.

...