Rising food and gasoline prices lifted U.S. consumer inflation as expected in March, but underlying inflation pressures remained contained, a government report showed on Friday.

The mild rise in core CPI -- which excludes food and energy and is watched by the Federal Reserve for monetary policy -- may be seen as vindication for officials at the U.S. central bank who have viewed the recent energy price spike as having a temporary effect on inflation.

The Labor Department said its Consumer Price Index increased 0.5 percent after rising by the same margin in February. That was in line with economists' expectations.

Core CPI edged up 0.1 percent, after gaining 0.2 percent the prior month and below economists' expectations for a 0.2 percent rise.

The Fed is not going to see inflation as a threat so they have the freedom to keep interest rates low longer, said David Wyss, chief economist at Standard & Poor's Ratings Services in New York.

But core inflation is creeping up from its lows six months ago, so the Fed is going to end its extraordinary measures, he added.

The Fed's policy-setting committee meets April 26-27 and debate is most likely to center on the timing of the withdrawal of some of the massive stimulus it has lent to the economy.

Weak labor costs, which account for the bulk of a company's expenses, should keep inflation pressures contained. The report showed real average hourly earnings fell 0.6 percent in March after declining 0.5 percent the prior month.

U.S. stock index futures rose after the data, but sentiment was cautious after Bank of America Corp said mortgage-related costs added to a drop in profit. U.S. Treasury debt prices rose, while the dollar extended losses against the yen.

Food and gasoline prices accounted for almost three quarters of the rise in overall consumer inflation last month. Gasoline rose 5.6 percent, increasing for a ninth straight month, and the index has now risen 14.4 percent over the last three months.

Food rose 0.8 percent, the largest gain since July 2008, after increasing 0.6 percent in February.

Core inflation last month was lifted by housing and transportation costs. Shelter costs, which account for about 40 percent of core CPI, rose 0.1 percent, rising by the same margin for a sixth straight month as the recovering economy boosts demand for rental apartments.

There were also increases in new and used vehicle prices, air fares and medical costs. Apparel prices fell 0.5 percent after dropping 0.9 percent in February.

In the 12 months to March, core CPI rose 1.2 percent year-on-year after advancing 1.1 percent in February. Fed officials, however, would like to see that closer to 2 percent.

Overall consumer prices rose 2.7 percent year-on-year, the largest gain since December 2009, after increasing 2.1 percent in February.

(Reporting by Lucia Mutikani, Editing by Andrea Ricci)