OTTAWA (Reuters) -Canada's annual inflation rate unexpectedly accelerated to 2.9% in May while key measures of core inflation edged up for the first time in five months, data showed on Tuesday, in an unfavorable reading for July interest rate cut prospects.

Money markets slashed their bets for a rate cut in July to around 54% from 65% before the numbers were released.

The Canadian dollar pared early losses and strengthened by 0.8% to 1.3643 against the U.S. dollar, or 73.30 U.S. cents.

Analysts polled by Reuters had forecast inflation to cool to 2.6% from 2.7% in April. Month-over-month, the consumer price index was up 0.6%, exceeding a 0.3% rise forecast.

The surprise acceleration in headline inflation was driven by prices for services including cellular services, travel tours, rent and air transportation, Statistics Canada said.

CPI-median and CPI-trim, the Bank of Canada's preferred measures of underlying inflation, rose for the first time since December, contrary to market expectations.

CPI-median sped up to 2.8% from 2.6% in April while CPI-trim accelerated to 2.9% from 2.8%. Economists had forecast CPI-median to remain at 2.6% and CPI-trim to be 2.8%.

Citing progress in bringing down inflation, the central bank lowered its policy rate to 4.75% earlier this month and said decisions to ease further would be dependent on data and taken one at a time.

Headline inflation is in line with the Bank of Canada's forecast of 2.9% by the end of the first half of 2024. The bank will have another month of inflation data before its next rate announcement on July 24.

In May, grocery price growth accelerated for the first time since June 2023, Statscan said, noting that prices for groceries have risen 22.5% compared with May 2020. Annual energy price inflation slowed to 4.1% from 4.5% in April.

Excluding volatile food and energy, prices rose 2.9% compared with a 2.7% rise in April.

Overall, service prices increased 4.6% in May, compared with a 4.2% rise in April, while goods inflation remained at 1%.

(Reporting by Ismail Shakil and Dale Smith, additional reporting by Promit Mukherjee; Editing by Emelia Sithole-Matarise)

By Ismail Shakil