Consumer prices in the metropolitan area rose last month compared with a year ago on higher residential rents.

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

It was the smallest such increase since December, when the index began rising more than 2 percent per month, year over year.

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

In addition, the cost of gasoline continued to rise, up 9.5 percent from May 2016.

Grocery prices were up 0.3 percent, year over year.

The cost of medical care and recreation increased 2.8 percent and 3.1 percent, respectively, from May 2016.

advertisement | advertise on newsday

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

These increases were partially offset by education and communication costs declining 0.6 percent, year over year. The category includes college tuition, postage, telephone services, computer software and accessories.