The consumer price index (CPI) rose from 2.7% the previous month, the Office for National Statistics said. Forecasters had predicted the rate to remain static in May.
Despite a fall in the price of motor fuels, higher prices for energy, food and recreational goods pushed the rate up.
This is the fourth consecutive month the inflation rate has exceeded the Bank of England’s 2% target.
The typical UK household will need to spend an extra £797 a year to maintain their standard of living enjoyed a year ago, according to Retirement Advantage.
Households are already feeling the pressure of rising prices and flat wage growth, with a report out yesterday from Visa showing spending fell for the first time in nearly four years in May.
Wage data out tomorrow is expected to confirm pay is shrinking in real terms, said Ben Brettell, senior economist at Hargreaves Lansdown.
High inflation is also bad news for savers as it erodes the real value of their cash.
According to Moneyfacts, not one of the 750 standard savings accounts on the market can outpace inflation.
The top-earning account from Atom Bank pays 2.3% and requires savers to tie their money up for five years. The best easy access account from Charter Savings Bank pays 1.11%.
Brettell said: “The general mood on the economy has become one of caution over the past few weeks, with first-quarter GDP figures disappointing, consumer spending looking weaker and Brexit-related uncertainty looming large.
“However, growth is expected to pick up somewhat in the second quarter, and it looks like the election result could make for a ‘softer’ Brexit, which could prove positive for the economy.”
He added: “Bank of England policymakers had previously said they expect inflation to peak at a little below 3% in the fourth quarter, but the evidence so far points to a sharper rise than anticipated. Just one member of the MPC, Kristin Forbes, has been voting for higher interest rates, and she leaves the committee next month.
“The balance of probability suggests the Bank will continue to ‘look through’ higher inflation and leave rates on hold to support the economy, but if inflation continues to surprise we could start to see members revising their positions.”