The housing market in the Twin Cities ended the year the way it began with demand outpacing supply in some areas. But along the way, prices rose to record highs and listings fell to stifling lows.

In December, home sales increased 2.6 percent while prices gained 4.1 percent, according to a year-end report from the Minneapolis Area Association of Realtors. Those modest monthly gains capped a year of extremes in which there were nearly 60,000 home sales, a 6.2 percent increase over the previous year and by a very narrow margin the third-most in history.

The median price of those sales last year rose to a record $232,000, 5.5 percent higher than the previous year and a nearly 40 percent increase since 2012.

By the end of the year, there were only 8,197 houses on the market, 26 percent fewer than the previous year and a 14-year low.

“The most important achievement of 2016 was erasing the losses in prices and equity caused by the downturn,” said Cotty Lowry, president of the Minneapolis Area Association of Realtors.

By nearly every measure, the 2016 housing market was a standout. It trailed only 2004, the highest-selling year, and 2005 in total sales.

But for those on the hunt for their first house and for people trying to sell an expensive one, it could be painful. The shortage of listings put the brakes on some sales, and the strongest demand was for the least-expensive houses.

During the year there were nearly 77,000 new listings, slightly fewer than the previous year, but closings and pending sales increased far more. At the end of the year there were just 8,197 houses on the market, 26 percent fewer than the previous year and one of the lowest on record.

“Sales may have been suppressed due to many buyers being unable to find or win in multiple offers a home of their choice,” said Pat Paulson, a sales agent and co-chair of the Realtors association’s research and technology committee.

At the end of December, there were only enough houses on the market to last 1.6 months. With first-time buyers and downsizing retirees driving sales, the stiffest competition was for the least-expensive listings. In the $150,000-to-$190,000 price range, for example, there were only enough properties on the market to last about a month and a half while there were enough listings priced at more than $1 million to last more than year.

On average, houses sold within 64 days last year, 16 percent faster than the previous year. And buyers paid 97.5 percent of the original asking price, the most in at least a decade.

Entry-level buyers sometimes had just hours to decide whether to make an offer. “The problem, as I see it, is buyers, especially in the lower price ranges, are pressured to make decisions faster than they are comfortable,” Paulson said.

Throughout the year, buyers were motivated by the threat of higher mortgage rates, rising rents and solid job gains, bolstering confidence in the market. And 2016 was marked by solid gains in new construction, especially in first- and second-ring suburbs.

Lake Elmo, east of St. Paul, posted the biggest gain in sales, with closings increasing 117 percent over the previous year. Tonka Bay, a small community on Lake Minnetonka, had a 46 percent increase in the median price of home sales in the community — the highest in the metro last year.

It was also the year of the disappearing distressed sales. With negative equity rates returning to normal levels and mortgage defaults plummeting, short sales represented a fraction of all listings. And foreclosure sales fell for the fifth straight year to levels not seen since 2007.

“We reached some key milestones last year,” said Tina Angell, president of the St. Paul Area Association of Realtors, “and hope to continue with this momentum in 2017.”