Statscan also said second-quarter annualized growth was set to be 2.5%, better than the Bank of Canada's July 14 forecast of 2.0%. Analysts predicted the third quarter would be stronger.

"With virus cases generally low across the country, the economy has some open road to recover even more ground this summer," Royce Mendes, senior economist with CIBC, said in a note.

Statscan said growth in retail trade and accommodation and food services was boosted by the easing of public health measures in many of Canada's 10 provinces in June.

There were also gains in manufacturing and mining, quarrying, and oil and gas extraction.

"The strong handover from June means that GDP should accelerate in the third quarter to around 6% annualized," said Stephen Brown, senior Canada economist at Capital Economics.

The Canadian dollar was trading nearly unchanged at 1.2441 to the greenback, or 80.38 U.S. cents.

The Bank of Canada, which says third-quarter annualized growth should be 7.3%, has identified possible new variants of COVID-19 as a potential threat.

"There remain challenges on the horizon, most notably in the form of variants of the virus which have slowed progress towards healing in other developed economies," Mendes said.

The economy shrank by 0.3% in May, matching a forecast from analysts polled by Reuters. Statscan revised April's decline to 0.5% from an initial 0.3% drop.

In May, 12 of 20 industrial sectors posted decreases, with services-producing industries down by 0.2% and goods-producing industries contracting by 0.4%.

(Additional reporting by Fergal Smith in Toronto;Editing by Alex Richardson, Jane Merriman and Paul Simao)

By David Ljunggren