OTTAWA -- Canada unexpectedly swung back into a trade deficit in February, ending three straight months of surpluses, on a broad-based decline in exports.

The trade report marks the first piece of disappointing Canadian economic data in arguably months, after a string of strong indicators prompted forecasters to lift their outlook for Canadian growth in 2017. The setback in trade could provide cover for Bank of Canada Gov. Stephen Poloz, who has stuck to a cautious, dovish tone amid improving data due to uncertainty in U.S. trade policy and the competitiveness challenges faced by Canadian exporters.

Canada posted a merchandise trade deficit with the rest of the world in February of 972 million Canadian dollars ($726.2 million), Statistics Canada said on Tuesday. Market expectations, according to economists at Royal Bank of Canada, were for a C$600 million trade surplus. This ended a three-month streak of trade surpluses, or the best performance on the Canadian trade front since the sudden drop in commodity prices over two years ago.

The previous month's figures were also revised, and now suggest a narrower trade surplus for Canada in January of C$421 million versus the earlier estimate of C$807 million.

In February, exports fell 2.4%, or the biggest month-over-month drop in 11 months, to C$45.34 billion. The level of exports hit a fresh high in the previous month after four consecutive monthly advances. On a 12-month basis, exports rose 4.4%.

The data agency said eight of 11 sectors tracked recorded declines in the month, led by agriculture and food products, down 10.6%; consumer goods, down 4.3%; and energy products, down 2.6%.

Excluding energy products, sales of Canadian-made goods abroad also declined 2.4%.

Imports rose 0.6% to C$46.31 billion in February, and advanced 1.4% on a year-over-year basis.

On a volume basis, exports in February fell 2.5% and imports rose 0.3%.

"We believe the report reinforces the Bank of Canada's desire to look through other more upbeat data and remain focused on the recovery in exports and business investment, which remains far from robust at this stage," said Brittany Baumann, economics strategist at TD Securities.

Meanwhile, U.S. trade figures were also released Tuesday, and indicated U.S. trade deficit shrank sharply in February, as exports rose 0.2% while imports fell 1.8%.

The latest merchandise trade data emerges a day after the Bank of Canada's business-outlook survey indicated further strengthening of domestic economic activity, supported by a recovery in the country's energy sector and foreign demand. Firms surveyed said the favorable effects of a weaker Canadian dollar versus the U.S. dollar boosted sales abroad.

The survey said firms expected "somewhat faster export growth" over the next 12 months, in light of improving indicators for future sales from foreigners. However, the survey noted exporters were "wary" amid "elevated uncertainty about potential U.S. policy changes." President Donald Trump has vowed to renegotiate better terms for the U.S. in the North American Free Trade Agreement, of which Canada is a partner. Roughly three-quarters of all Canadian exports, or the equivalent of 20% of the country's gross domestic product, are U.S. bound.

The Bank of Canada has singled out policy uncertainty in Washington as a reason to remain cautious, with Mr. Poloz telling reporters he would prefer to wait and see how developments transpire. He has also cited the amount of slack, or unused production and labor capacity, that persists in the economy.

On a regional basis, exports to the U.S. fell in February 1.2%. On a 12-month basis, sales to the U.S. increased 4.9%. Exports to countries other than the U.S. fell 5.9% in February, but rose 2.9% on a year-over-year basis.

Write to Paul Vieira at paul.vieira@wsj.com