WASHINGTON — The overall Consumer Price Index increased for the first time in four months, climbing 0.3% in July after falling 0.1% in June, 0.2% in May and 0.1% in April. At 217.6, the index was up 1.2% over the past 12 months, according to the Bureau of Labor Statistics of the Department of Labor. The index for food and beverages, meanwhile, finished virtually unchanged for the third straight month at 219.6.

The energy index posted its first increase since January and accounted for more than two thirds of the increase in the overall index. Both the gasoline and household energy indexes advanced in July after a series of declines, the B.L.S. said.

The food index, meanwhile, fell 0.1%, to 219.2, largely due to the fourth consecutive decline in the fruits and vegetables index, which declined 1.9% to 269.3. The fruits and vegetables index declined 1.3% in June and 1.1% in May.

Also sustaining declines in the month were the index for cereals and bakery products, which eased 0.3% to 248.6, and the index for food at home, which fell 0.1% to 215.4.

The biggest gainers during the month were nonalcoholic beverages, which rose 0.6% to 161.8, and dairy and related products, which rose 0.5% to 198.9.

The index for meats, poultry, fish and eggs, which has been the big mover in recent months, rose 0.3% to 209.2, which comes on the heels of gains of 1% in June and 0.4% in May.

For the past 12 months the food index has risen 0.9%.