This was mainly due to the increasing cost of meat products, particularly bacon, and vegetables.
Increasing household energy bills were also a significant factor, along with the rising cost of books, stationery and foreign holidays.
However, this rise in the cost of leisure and recreation was offset by a fall in the price of DVDs, according to the ONS.
If inflation rises more than one percentage point above the government's 2% target, the Bank of England governor must write a letter to the government to explain what action it is taking to control consumer prices.
In his letter to the chancellor, Bank of England governor Mervyn King blamed sharp rises in the prices of food and energy for the increase in the rate of inflation.
The global nature of these price changes is evident in inflation rates not only in the UK, but also overseas
"As things stand, inflation is likely to rise sharply in the second half of the year, to above 4%," Mr King told the chancellor.
"I must stress however, that there are considerable uncertainties, in both directions, around this, and any such projection is particularly sensitive to changes in domestic gas and electricity prices," he said.
Mr King has had to write such a letter to the chancellor only once before, when inflation hit 3.1% in April 2007.
The governor said that the rate of inflation should peak towards the end of this year, as long as there were no "unexpected increases in oil and commodity prices".
Should the UK avoid severe external shocks, then the rate of inflation will begin to fall back towards the 2% target next year, Mr King said.
In reply, Chancellor Alistair Darling agreed with the Bank of England's assessment for the rising rate of inflation.
The two main opposition parties have criticised the Labour Government for the rising cost of living.
They blame years of borrowing for sustaining the economic boom of the past few years, which means now the government cannot afford to make tax cuts or offer financial incentives to help consumers.
Shadow chancellor George Osborne said: "Gordon Brown's economic reputation has gone bust. His years of boom and borrowing have left Britain ill prepared to face the double evil of rising inflation and falling growth."
The higher-than-expected rise in consumer price inflation has transformed expectations for interest rates, according to the BBC's Economics Editor, Hugh Pym.
He also suggested that prices will rise at a faster rate in the coming months.
To return now to inflationary pay settlements would undermine rather than raise people's living standards
Confident talk of two or more cuts in borrowing costs from the present level of 5% has been replaced by forecasts of unchanged or even higher rates in the months ahead, our editor says.
Mr King and his colleagues are unlikely to cut interest rates further until they are convinced that the inflationary threat has passed - despite pleas from those struggling in the housing market.
However, analysts warn that raising interest rates to curb inflation could dampen an economy already dented by slowing growth and the weakening housing market.
"The key factor [deciding the direction of interest rates] will be whether increased inflationary expectations feed through into greater wage demands and second round effects – at the moment average earnings growth is stable, but the MPC will be watching it closely through 2008," said economist Charles Davis from the Centre for Economics and Business Research.
In his letter, the chancellor called for "restraint" in pay rises awarded in both the public and private sector.
"To return now to inflationary pay settlements would undermine rather than raise people's living standards, with a damaging circle of wage increases eroded by steadily increasing prices," the chancellor said.
Prime Minister Gordon Brown said ministers would not accept a pay rise for this financial year.
A simple guide to inflation by Richard Scott
Consumers and companies around the world have been feeling the effects of higher energy and food bills.
"The global nature of these price changes is evident in inflation rates not only in the UK, but also overseas," Mervyn King said.
In the past 12 months, world agricultural prices have increased by 60% and retail food prices by 8%, the governor said.
Oil prices have nearly doubled over the past year and on Monday the price hit a fresh high of almost $140 a barrel in New York.
Wholesale gas prices are up by about 160% in the past year and UK household energy bills have risen by about 10%.
Those increases have prompted many people to rein in their spending in other areas.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.