Open this photo in gallery:

A customer shops for produce at a FreshCo grocery store in Brampton, Ont.Chris Young/The Canadian Press

Canada’s annual inflation rate cooled more than expected to 2.8 per cent in June, data showed on Monday, as gasoline costs fell sharply after the U.S. and Iran signed their memorandum of understanding to end the war.

The war has since then flared up again in the Middle East and gasoline costs have started inching up.

The Consumer Price Index on a month on month basis decelerated by 0.4 per cent, Statistics Canada said.

Analysts polled by Reuters had forecast an annual inflation rate of 2.9 per cent and a monthly inflation rate of -0.2 per cent in June.

Last month, the consumer price index had clocked a 29-month high of 3.2 per cent, breaching the Bank of Canada’s control range of 3 per cent in more than two years.

With one year left for Macklem, it’s still one battle after another

Gasoline prices were the biggest contributor to the easing in inflation rate with price of the fuel purchased at the pump falling by over 10 per cent in June, Statscan said. On a year over year basis, gasoline costs rose at a rate of 20.5 per cent in June, down from a rise of 33.2 per cent in the prior month.

Excluding gasoline, the CPI was unchanged in June compared with May, at 2.2 per cent, Statscan said.

Due to a continued increase in gasoline prices, transportation costs, which accounts for around 18 per cent of the CPI basket, rose by 6.7 per cent in June on an annual basis.

Other items in the basket that grew at more than 3 per cent were food, which rose by 3.5 per cent in June, and the recreation, education and reading category, which increased by 3.8 per cent, data showed.

However, the rise in grocery prices cooled slightly with the cost of food purchased from stores rising by 3.9 per cent on an annual basis last month, down from 4.3 per cent in May. June was the 17th consecutive month that grocery price inflation outpaced the all-items CPI.

The core measures of inflation, closely watched by the BoC to gauge underlying inflation trends, eased further in June. CPI-median was down to 1.9 per cent from 2.1 per cent in May, while CPI-trim fell to 1.8 per cent from 2 per cent in the prior month.