U.S. consumer prices were flat in July versus June as expected, but fell over the past 12 months by the most since 1950, government data showed on Friday.

The Labor Department said its Consumer Price Index was unchanged after rising 0.7 percent in June, in line with market forecasts for a flat reading.

Gasoline prices fell 0.8 percent after jumping 17.3 percent the previous month, helping to keep overall prices contained. The food index declined 0.3 percent, the biggest fall since May 2002, after being flat in June, while prices for apparel and new vehicles rose in July.

Compared to the same period last year, consumer prices fell 2.1 percent, the largest decline since January 1950.

Stripping out volatile energy and food prices, the closely watched core measure of consumer inflation rose 0.1 percent in July after increasing 0.2 percent in June. That was also in line with market expectations for a 0.1 percent gain.

Compared to July last year, the core inflation rate rose 1.5 percent, the slowest advance since February 2004, after increasing 1.7 percent in June.

(Reporting by Lucia Mutikani; Editing by Andrea Ricci)