Long Island home prices jumped last month as buyers encountered a shortage of homes for sale.

Homes in Nassau County sold for a median price of $505,000 in March, up 8 percent from a year earlier, the Multiple Listing Service of Long Island reported Friday. Suffolk County homes fetched a median price of $352,000, up 6.7 percent from the previous March.

There were only 4,422 homes for sale in Nassau, down 6 percent year-over-year, and 6,048 in Suffolk, a 15 percent annual decline.

“We have houses selling in three days, three weeks, and a lot of them still have multiple offers on them due to the shortage of inventory,” said Al Pantino, general manager of Bon Anno Real Estate in Massapequa.

Sales activity fell in both counties, with closed deals falling by 10 percent in Nassau and 8.2 percent in Suffolk, compared with the same period last year. Buyers signed fewer contracts last month as well, with an annual decline in pending sales of 2.9 percent in Nassau and 1.1 percent in Suffolk.

With interest rates rising, “the first-time buyer is really getting squeezed now,” Pantino said.

The average mortgage interest rate was 4.42 percent this week, up 0.34 percentage points from a year earlier, mortgage giant Freddie Mac reported.

“If the rates hit 5 [percent], it’s going to get certain first-time buyers to just take a pause, they’re going to have a harder time qualifying for these mortgages,” Pantino said. “Houses at that point might stay on the market a little bit longer.”