Analysts polled by Reuters had forecast GDP would fall 0.1% in July from June. Statistics Canada said growth in goods-producing industries more than offset the first decline in services-producing industries since January.

Oil sands extraction jumped 5.1% in July on higher output, partially offsetting two months of declines. Canada's agricultural sector also helped drive economic growth, with crop production up 7.2%, mainly on volumes of wheat and other grains.

Demand for Canadian wheat has increased since Russia's invasion of Ukraine, which Russia calls a special military operation, helping push up export volumes.

The retail trade sector contracted sharply in July, falling to its lowest level since December 2021, led down by a 7.1% decline in output at gasoline stations, Statscan said.

Still, the decline in retail trade most likely reversed in August, Statscan noted in its flash estimate.

Accommodation and food services also contracted in July, again the first decline since January, driven by less activity at bars and restaurants.

The Canadian dollar was trading 0.7% lower at 1.3695 to the greenback, or 73.02 U.S. cents, giving back much of its previous day's gains.

(Reporting by Julie Gordon in Ottawa, additional reporting by Dale Smith in Ottawa and Fergal Smith in Toronto; Editing by Nick Zieminski)

By Julie Gordon