– When home sales weaken, prices typically do, too, and buyers benefit.

Not quite this time. Home purchases in many areas of the country have dipped, and price gains have slowed. Yet a rising number of middle-class Americans are finding that homeownership is unaffordable.

Why? Mortgage rates are up after years near historic lows. Price increases have been outrunning paychecks. And at a target price that families with a median income could afford, fewer homes are for sale.

In the past year, the availability of homes that a middle-class family could buy has declined in 86 percent of the largest metro areas, according to an analysis of 49 cities that released Wednesday by the real estate brokerage Redfin.

That figure assumes a 20 percent down payment. If a buyer can put only 10 percent down — common among first-timers — the number of affordable listings fell in 94 percent of those metro areas, Redfin found.

"Housing prices went up so much in 2017 and the first half of 2018 that we reached a point where buyers just couldn't pay these high prices," said Daryl Fairweather, chief economist at Redfin.

The effect of those unsustainable price gains is evident in the slumping year-end sales totals tracked by the National Association of Realtors. Sales tumbled 3.1 percent last year to 5.34 million, the fewest since 2015, the Realtors reported Tuesday.

The strong economy offered little support to would-be buyers because mortgage rates climbed for much of last year, making purchases costlier. Though more homes are on the market compared with 2017, they are increasingly clustered in price ranges that only the affluent or wealthy can afford.

The Redfin analysis found that on average, 55 percent of homes listed for sale were affordable with a 10 percent down payment. That was a drop from 60 percent in 2017. A higher 20 percent down payment would make monthly payments more manageable, but loan data suggest that a growing number of first-time buyers can't put down 20 percent.

In metro areas long known for affordable home values — Milwaukee, Memphis, Pittsburgh, St. Louis, Phoenix and others — the number of homes for sale that a household with a median income could afford has slipped.

The trend poses a major risk for many Americans: Household equity is the principal source of wealth for middle class households; without it, many would struggle to build much wealth at all.

The median net worth of an American homeowner is $231,400, according to the Federal Reserve. That is more than 44 times the median net worth of renters, which is $5,200. The median net worth of homeowners surged by an inflation-adjusted 15 percent from 2013 to 2016, according to the Fed, while renters actually became poorer over that time.

Home affordability has been worsening since the real estate market bottomed in 2012. The recovery in home values has easily surpassed gains in typical paychecks.

Nationally, home values have climbed 44 percent on average since 2012 but incomes only about 15 percent, according to Tendayi Kapfidze, chief economist at the online loan broker LendingTree.

If the housing market is to accelerate again, he added, incomes will need to start rising faster than home values or home values must decline.