Home buyers priced out of the city surged into Long Island’s housing market this spring, even as demand for luxury real estate in the Hamptons cooled off.

On Long Island, excluding the East End, the number of sales jumped to 6,324 in the April-through-June quarter, almost 21 percent more than a year earlier, according to reports to be released Thursday by the brokerage Douglas Elliman and the Manhattan-based appraisal company Miller Samuel. The median price ticked up to $382,500, a 2 percent annual gain.

Home Search

Search Newsday for over 100,000 homes

For young adults having their first or second child, “you either stay in the city and live in a cubicle, or you can buy a pretty nice house” on Long Island, said Dottie Herman, chief executive of Manhattan-based Douglas Elliman.

However, Herman said, stagnant salaries are keeping a lid on prices.

Even as demand jumped across most of Long Island, the number of Hamptons sales fell by more than 20 percent annually, to 561 in the second quarter, the reports showed. The median Hamptons home price increased year-over-year by 4.3 percent, to $975,000.

The North Fork saw a modest uptick in activity, as the number of sales increased by 4.7 percent, to 179, and the median price rose by 2.9 percent, to $535,000.

advertisement | advertise on newsday

One Hamptons community going through a lot of changes is Hampton Bays, where local officials and home buyers are fixing up long-neglected properties, Herman said. “That was really the working man’s haven,” she said. Now, she said, “they’re building condos that are going for $1.5 million.”

The Hamptons luxury market boomed from 2013 through much of 2015, so this year’s decline in sales is a “reset” to a more sustainable level of activity, said Jonathan Miller, chief executive of Miller Samuel.

Many Hamptons homes were “simply not priced to sell in this market,” and overly ambitious homeowners have either dropped their asking prices or taken homes off the market, Miller said.

Plus, Miller said, some buyers are staying on the sidelines due to uncertainty about the U.S. presidential election and financial turmoil abroad.

Some would-be Hamptons buyers are now renting until they “fall in love” with a home, but activity is picking up in July, said Ernest Cervi, Corcoran’s regional senior vice president for the East End.

In Sag Harbor, high-end condominiums at a refurbished former factory now called the Watchcase have nearly sold out, Cervi said. The median price in Sag Harbor was nearly $1.2 million in the second quarter, up 27 percent from a year earlier, a Corcoran report to be released Thursday shows.

The Watchcase has drawn a mix of young adults, families and seniors, Cervi said.