Fiscal cliff fears threw the Manhattan apartment market into a year-end frenzy as thousands of sellers rushed to offload their homes before tax rates went up.

Apartment sales, especially in the high end, surged in the last three months of the year, according to real estate reports released Wednesday.

One tally, from brokerage firm Brown Harris Stevens, said closings jumped a whopping 40% to 2,297.

Prompting the big rush were sellers’ concerns that capital gains tax rates would go up.

Sure enough, the fiscal cliff deal lifted capital gains taxes from 15% to 20% for single taxpayers earning above $400,000 and couples earning more than $450,000. As of Jan. 1, health care reform adds a new 3.8% surtax on capital gains for wealthy Americans, pushing the top rate to 23.8%.

So those who got in under the wire saved a bundle.

“There was a real push to get deals closed, especially at the high end where the tax changes could mean a lot of money,” Hall Willkie, president of Brown Harris Stevens, said.

Sales of trophy properties led the way, with a 44% jump in apartments priced over $10 million this quarter compared with last year, the real estate brokerage said. At the top of the heap was the penthouse at 785 Fifth Ave. — purchased by media mogul David Geffen from socialite Denise Rich for $54 million, a record for a co-op sale.

The deal mania was so strong that “in the first week of December we had to stop accepting appraisal assignments,” said Jonathan Miller, CEO of real estate appraisal firm Miller Samuel.

Pumped up by brisk sales of luxury properties, the average price of a Manhattan apartment rose 7%, to $1,486,692, compared with last year, Brown Harris Stevens said.

Overall last year, an improving economy and record-low interest rates gradually lifted Manhattan apartment prices, which are now 9% below the peak reached in 2008, according to Streeteasy.com.

But there could be clouds ahead. The supply of apartments on the market has dipped, and would-be sellers are holding back, afraid they won’t be able to trade up.

With taxes rising, “potential buyers will be able to afford less, and potential sellers will find it more expensive to sell their homes,” warned Sofia Song, Streeteasy’s vice president of research.