The steeper-than-expected increase in the Consumer Price Index (CPI) measure of inflation, from a four-and-a-half-year low of 1.5% in May, saw it climb to its highest level since the start of the year.
This may exert pressure on policy-makers as they consider when to hike interest rates which have been at the historic low of 0.5% for more than five years.
Compare savings rates: earn up to 6.4%
But the figures from the Office for National Statistics (ONS) also mean that CPI has been at or below the 2% target for seven months in a row, the first time this has happened since 2005.
Inflation had been dragged down by the supermarket price war which saw food and non-alcoholic drinks costs fall in May but these were flat in June.
Meanwhile clothing and footwear prices rose month on month at a time when they are usually falling - as this time stores held off on summer discounts as warm weather brought shoppers out.
Furniture, air fares and sea transport also had an upward effect but petrol prices went up by less than the same month a year before.
Today's data showed the Retail Prices Index (RPI) measure of inflation, which includes housing costs, rose from 2.4% to 2.6%.
Sterling jumped back above the 1.71 US dollar mark on expectations that the latest figures will raise the chances of an interest rate hike.
Jeremy Cook, chief economist at currency company World First, said the rise in inflation was a "big surprise".
He added: "This will encourage those economists and rate-watchers looking for a tightening of Bank of England monetary policy this year, but for those who are seeing below-inflation wage increases, the situation just got a little more painful."
Chris Williamson, chief economist at Markit, said: "With inflation almost hitting the Bank of England's 2% target, the housing market booming, the economy growing strongly with no signs of momentum being lost and unemployment plummeting, the case for higher interest rates is building."
Howard Archer, chief UK and European economist at IHS Global Insight, said: "June's rise in inflation is disappointing news for both consumers and the Bank of England.
"The rise back up in inflation squeezes consumers' purchasing power, especially as earnings growth currently remains muted."
Samuel Tombs, of Capital Economics, said the sharp rise in inflation was likely to be reversed soon, with the supermarket price war meaning a significant rise in food price inflation seemed unlikely.
He said the full impact of the strong pound was also yet to be felt, while a fall in wholesale gas and electricity prices could dampen energy bill hikes this winter.
"We maintain our long-standing forecast that CPI inflation could ease to about 1% by the end of this year and remain below the 2% target in 2015," he said.
"Not only would this enable real earnings to finally stage a recovery, but it should also give the MPC (Monetary Policy Committee) scope to raise interest rates only gradually next year."
James Knightley, of ING Bank, said inflation was likely to remain subdued in the near term but that the improving economic picture should see a "gradual build-up in domestic inflation pressures".
With the Bank of England looking ahead to the picture in two years' time, this was likely to mean a first interest rate hike in November this year, he said.
"This would also remove political concerns of waiting until early next year when election campaigning is in full swing," he added.
A Treasury spokesman said: "The Government's long-term economic plan is working, with today marking the sixth consecutive month that inflation has been below the Bank of England's 2% target."
The pound surged on the higher-than-expected rise in inflation, climbing a cent against against the greenback as it headed close to 1.72 US dollars and also adding a cent against the single currency to breach the 1.26 euros mark.
Sterling has been trading at near six-year highs on increasing expectations of an interest rate hike - which were further fuelled by the latest data.
But David Kern, chief economist at the British Chambers of Commerce (BCC), said the inflation figures "should not spark a knee jerk reaction on interest rates by the Monetary Policy Committee (MPC)"
"Monthly fluctuations in the inflation figures are normal and there are no significant upward pressures, particularly as wage growth remains weak," he said.
"The UK recovery is still not secure and growth amongst UK businesses must be fostered prior to any future interest rate rises."
Meanwhile Labour and the unions focused on the impact of higher inflation on the cost of living.
TUC general secretary Frances O'Grady said: "It is becoming harder for people to get by as average wages continue to fall behind the rising cost of living. Ministers may have moved on from Britain's living standards crisis but it's still the top concern for families.
"An economic recovery based on shrinking pay packets is not one built to last."
Shadow treasury minister Catherine McKinnell MP said: "This is a worrying jump in inflation, yet David Cameron continues to deny there's a cost-of-living crisis."
Compare savings rates: earn up to 6.4%