Gas prices surged 3.3% in April, driving the entire Consumer Price Index higher during the month. Click the photo to see gas prices in your state.

NEW YORK (CNNMoney) -- Inflation accelerated to its fastest annual pace in two and a half years in April, as surging gas prices continued to hit American consumers.

The Consumer Price Index, the government's key inflation measure, rose 3.2% over the last 12 months ended April 30, according to Friday's report from the Labor Department. It was the biggest 12-month jump since October 2008.

More than half of the increase was due to rising energy prices, the government said.

Gas prices alone surged 3.3% in April, and are up 33.1% over the past year.

Meanwhile, food prices rose 0.4% during the month, or 3.2% over the last 12 months.

Both gas and food are prone to volatile price swings, often due to weather disruptions and geopolitical conflicts abroad. During the last few months, both have surged due to uprisings in the Middle East, damaged agricultural crops and increased demand during the economic recovery.

That's why most economists and the Federal Reserve often look at the core CPI, which strips out gas and food, as a better indicator of long-term inflation.

Core-CPI was up 1.3% from a year ago, in April -- the largest year-over-year increase since February 2010.

That rate is considered well below the Fed's target rate of 2% a year, and economists take some comfort in a low core-CPI as an indication that long-term inflation is not a major threat to the economic recovery.

Plus, commodities including oil have started to fall recently, indicating that the rise in consumer prices may be near its peak.

"I don't see inflation as running at high enough levels to threaten the recovery, especially now that we're seeing signs that gasoline prices have peaked," said David Resler, chief economist at Nomura Securities. "If that proves to be the case, we can all breathe a little easier."

Monthly data: Overall, prices jumped 0.4% in April, in line with forecasts from economists surveyed by Briefing.com.

Core CPI rose 0.2% during the month, surpassing economists' forecasts, which called for a 0.1% tick higher.