Clothing, food and non-alcoholic drinks and the air transport sectors pushed the rate higher, according to the ONS. It marks a significant uptick from May, when CPI inflation came in at 1.5 percent.
Sterling hit a session high against the dollar on the news, rising to $1.7133.
Naeem Aslam, chief market analyst at AvaTrade, said the uptick in inflation was likely to increase expectations of an interest rate rise by the Bank of England (BoE) sooner rather than later.
"Yes, everyone was expecting a good number, but this is a firm number which has tattered the (BoE's inflation) forecast," he said in a note.
"The odds are even higher now that we may get the rate hike by the end of this year which could very well be during their meeting in November."