U.S. consumer prices rose in July and the underlying trend continued to strengthen, pointing to a steady increase in inflation pressures that keeps the Federal Reserve on track to gradually raise interest rates.

The Labor Department said on Friday its Consumer Price Index advanced 0.2 percent, the bulk of which was due to a rise in the cost of shelter. The CPI rose 0.1 percent in June.

In the 12 months through July, the CPI increased 2.9 percent, matching the increase in June.

Excluding the volatile food and energy components, the CPI rose 0.2 percent, the same gain as in May and June. The annual increase in the so-called core CPI was 2.4 percent, the largest rise since September 2008, from 2.3 percent in June.

Economists polled by Reuters had forecast both the CPI and core CPI rising 0.2 percent in July.

U.S. Treasury yields held at three-week lows after the data while the dollar rose slightly against a basket of currencies. U.S. stock index futures were down.

The Fed more closely tracks a different inflation measure, the personal consumption expenditures (PCE) price index excluding food and energy, which increased 1.9 percent in June.

That gauge hit the U.S. central bank's 2 percent target in March for the first time in more than six years and Fed policymakers have said they will not be unduly concerned if it overshoots its target in the coming months.