WASHINGTON (AP) — Sales of previously occupied homes fell in December for the first time in four months as many would-be buyers were frustrated by a lack of available houses, which fell to the lowest level in more than two decades.

Existing home sales dropped 4.6% last month from November, to a seasonally adjusted annual rate of nearly 6.2 million, the National Association of Realtors said Thursday.

The demand for homes remains healthy, the group said, with median prices jumping nearly 16% from a year ago to $358,000. Homes sold in an average of 19 days, slightly higher than in the summer but still quite rapid. Yet the number of houses for sale slumped to just 910,000 in December, the fewest since records began in 1999.

“It’s very hard for sales to meaningfully grow when there’s just not that much available to buy,” said Kwame Donaldson, senior economist for real estate website Zillow. “Existing home sales fell back to earth in December after an unexpectedly strong autumn. … This reversal can be traced to a dramatic decrease in options for buyers.”

The inventory of homes for sale has fallen 40% from pre-pandemic levels, Donaldson said.

Even with the December decline, it has been a healthy year for home sales. Annual sales reached 6.1 million in 2021, the National Association of Realtors said, up 8.5% from 2020 and the most since 2006, the height of the housing bubble that crashed the following year.

Sales soared after pandemic lockdowns ended and many Americans sought more space for indoor offices and online schooling. Healthy home-buying was also fueled by strong job and income gains.

The surge in new omicron infections may have discouraged some people from putting their homes on the market and opening them to extensive traffic, Donaldson said, driving inventory lower.

With the Federal Reserve set to raise interest rates as soon as March, home sales are expected to decline this year, said Lawrence Yun, chief economist for the Realtors.

Mortgage rates started to rise sharply in late December, after last month’s sales were mostly completed. The anticipation of higher borrowing costs likely drove home purchases higher in the fall. The average rate on a 30-year fixed mortgage reached nearly 3.6% this week, the highest since March 2020 and up from 3.05% a month ago.