An index of consumer prices in the metropolitan area rose last month compared with a year ago, pushed higher in part by rising residential rents.

The federal Bureau of Labor Statistics reported Friday that its consumer price index for the 31-county region that includes Long Island climbed 1.8 percent in June compared with June 2016.

The year-over-year increase was identical to that for May, which was the smallest rise since December when the index began rising more than 2 percent per month.

Martin Kohli, the bureau’s chief regional economist, said the cost of housing was a key factor behind the June gain in prices. Last month, residential rents climbed 2.7 percent from a year earlier, he said.

In addition, the cost of gasoline continued to rise, up 6.1 percent from June 2016.

Grocery prices were up 0.6 percent, year over year.

advertisement | advertise on newsday

The cost of medical care and recreation increased 2.6 percent and 2.9 percent, respectively, from June 2016.

Natural gas prices rose 13.6 percent last month compared with a year earlier. The cost of electricity climbed 2.8 percent.

These increases were partially offset by household furnishings and operation costs declining 0.5 percent, year over year.