A tightening supply of homes and brisk sales activity gave Long Island housing prices a boost last month.

Suffolk County saw the biggest increase in the number of closed sales, with 1,108 homes changing hands in May, up 13.4 percent from a year earlier, the Multiple Listing Service of Long Island reported Tuesday. Homes in Suffolk sold for a median price of $340,000 last month, up 3.3 percent from May 2015.

In Nassau County, the number of sales ticked up 1.6 percent, year over year, to 865. The median price in the county increased annually by 5.6 percent, to $459,500.

There were about 15,500 homes listed for sale across the Island last month, down nearly 16 percent from a year earlier, listing service figures show.

The low number of homes for sale — especially in the sought-after price range of $300,000 to $500,000 — is prompting bidding wars, said Steven Weisel, sales manager with Century 21 Dallow Realty in Farmingdale and North Bellmore.

In some cases, homes sell for more than the asking price, he said. “The supply is low, and the demand is obviously very high.”

advertisement | advertise on newsday

In both counties, real estate agents said the rising cost of apartments is driving some renters into the sales market.

“The rental market has reached a point that very often it’s more economical to buy instead of renting,” Weisel said. “If you’re paying $2,500 a month for rent, you probably, with your tax benefit, could afford monthly mortgage payments of $3,000 to $3,500.”

One-bedroom apartments cost a median $1,709 in Nassau County and $1,470 in Suffolk County last year, according to a recent report by the Long Island Index.

What’s more, low mortgage interest rates are giving buyers more purchasing power, said Barbara Wanamaker, broker-owner of Prime Properties in Huntington.

The average interest rate for a 30-year, fixed-rate mortgage was 3.6 percent last week, down 0.44 percentage points from a year earlier, mortgage giant Freddie Mac reported.

However, Wanamaker said, uncertainty about who will be the next president and fears about terrorism are prompting some buyers to hesitate. That’s especially true of millennials, or young adults up to age 35, she said. It doesn’t help that the amount of information online about homes for sale can be “overwhelming,” she said.

Some buyers have “a difficult time committing,” Wanamaker said. “They’re unsure about the way their world is going — the economy, jobs — they’re unsure if they’re going to have enough money to continue paying for a house, and a lot of them are unsure whether they want or need a house.”