The rising cost of foreign package holidays and imported computer games helped to push the UK inflation rate up to 2.9% last month from 2.7% in April.
The latest inflation rate is the highest since June 2013, and above the Bank of England's 2% target.
The Office for National Statistics said the price of food and clothing also went up slightly but fuel costs fell for a third month in a row.
The pick-up in inflation is likely to continue the squeeze on consumers.
The fall in the value of the pound since last year's Brexit referendum has increased the cost of imports, which has been one of the key factors behind the rise in inflation.
However, wage increases have not kept up with the rise in prices. The most recent ONS data on wages showed that average weekly earnings excluding bonuses increased by 2.1% in the three months to March. Earnings data for the three months to April will be released on Wednesday.
Computer games are part of the recreational and cultural goods and services sector, where prices rose overall by 0.9% between April and May compared with a fall of 0.4% a year ago.
As computer games are mostly imported they have been affected by the weaker pound, while the drop in sterling has also meant holidays abroad are more expensive.
The sugar, jam, confectionery and children's clothing markets were mainly responsible for the increase in food and clothing prices.
There were also rises in the price of furniture and household goods, and in the cost of electricity - with further price increases coming into effect in May.
Travellers did have some good news, however, with the decrease in fuel costs coupled with a drop in the cost of air and sea travel, which was influenced by Easter falling in April instead of March as in 2016.
Amit Kara, head of UK macroeconomic forecasting at the National Institute of Economic and Social Research, said: "We expect inflation to rise further over the course of this year and to reach a peak in the final quarter of 2017.
"This spike in inflation will exert further downward pressure on real household disposable income, at a time when wage growth remains modest and in turn squeeze consumer spending."
Nick Dixon, investment director at life insurance and pensions firm Aegon, said: "This high rate will particularly affect the purchasing power of retirees locked into a fixed income and the growing number whose wages have failed to keep pace."
When you hear politicians lament the squeeze on living standards caused by higher inflation and sagging pay rises, it's worth remembering another squeeze - one the largest parties are deliberately imposing.
The biggest single austerity measure, imposed first by George Osborne, is the freezing of "working-age" benefits. If you receive child benefit, tax credits or jobseeker's allowance, your benefits no longer rise with inflation.
Last year that made little difference because CPI inflation was zero. But with inflation now at 2.9%, the real value of your benefits is dropping sharply.
This is projected to cost benefit recipients (and therefore save the government) £3.6bn a year by 2021.
In addition, further cuts to universal credit chalked in by Mr Osborne (cutting the amount you can earn before tax credits are withdrawn and withdrawing extra support if you have more than two children) will take another £6bn a year off low-income families by 2020.
As the low-income think tank the Resolution Foundation points out, Labour may have said it will reduce welfare cuts by £2bn a year, but that's too little to reverse the cuts.
Both parties are effectively planning to keep the biggest austerity measures and the austerity "squeeze" on benefit recipients is only just beginning.
Samuel Tombs, chief UK economist at Pantheon Macroeconomics, said inflation looked set to peak at about 3.2% in the fourth quarter of the year, "as retailers continue to pass on higher import prices to consumers".
"We doubt, however, that a majority of MPC members will feel compelled to raise interest rates this year," he added.
Suren Thiru, head of economics at the British Chambers of Commerce (BCC), warned that businesses were being hit hard by the rise in inflation.
"Higher inflation is a key business concern as it squeezes margins and weakens their ability to invest, particularly during this time of heightened political uncertainty." he said.
"The BCC's quarterly economic survey confirms that businesses continue to feel the inflationary pressures, with a significant proportion of firms struggling to absorb the rising cost of raw materials and other overheads.
"If the current political uncertainty persists, this is likely to increase the downward pressure on sterling's value, pushing inflation even higher over the next year."
The ONS's new preferred measure of inflation CPIH - which includes a measure of owner occupiers' housing costs - rose to 2.7% last month, up from 2.6% in April.
The Retail Prices Index (RPI) measure of inflation increased to 3.7% in June, up from 3.5% the month before.