The annual inflation in the U.K. held steady at 2.8% in May despite higher petrol prices due to the U.S.-Iran war, as they were offset by lower food costs, official data showed Wednesday.

The consumer prices index (CPI) level matched April's reading, the Office for National Statistics (ONS) said, while analysts' consensus forecast had been for an increase to 3.0%.

"While the war in the Middle East pushes prices up globally, we have got the right economic plan, and inflation has held steady," Treasury chief Rachel Reeves said in response.

Even though the U.S. and Iran agreed this week to a deal to end the conflict, inflation could still rise in the coming months with energy costs remaining above pre-war levels.

The better-than-expected inflation data for May could, meanwhile, prove fruitless for the Labour government, which is facing a special vote Thursday expected to set in motion an attempt to oust Keir Starmer as prime minister.