The average sales price rose 8 percent over the same period last year, hitting $2.19 million. The median sales price also hit a record, up 7 percent to $1.19 million. While homes were sitting on the market slightly longer, inventory fell modestly.

The total number of sales jumped 15 percent compared with last year, to 3,153, according to the report from Douglas Elliman Real Estate and Miller Samuel Real Estate Appraisers and Consultants.

Despite soft sales in the second half of 2016 and an uneven start to the year that led many to predict a slowdown at the high end, sales in Manhattan showed surprising resilience in the second quarter.

Prices for Manhattan real estate hit a new all-time high in the second quarter, with apartments now selling for an average of $2.19 million, according to a new report.

"The expectation for the second quarter had been more modest," said Jonathan Miller, president of Miller Samuel. "We did see the market cool in April. But by May the market kicked in and the quarter ended up finishing strong."

Miller said the strong sales and prices were driven by two factors: more realistic sellers and continued pent-up demand from buyers who held off purchases in 2016.

"Sellers realized that if they wanted to move their property, they needed to be more realistic," he said.

Condos — especially new condos — continue to fuel the rise. The average condo sales price jumped 13 percent over the same quarter last year, to $3.12 million. Despite concerns about a glut of fresh condo towers in Manhattan, sales of new units continued to be brisk. The average sales price for new condos jumped 7 percent to $4.70 million. Inventory rose only slightly, to a 5½-month supply.

As for the rest of the year, Miller said that the very top of the market — multimillion-dollar apartments — will continue to be weaker than the entry-level market (entry level being a relative term in Manhattan). But, he said, the outlook for the upper end has improved.

"I think the upper half of the market is stronger than we think," he said.