A sold sign is posted in front of a home for sale in San Anselmo, Calif. / Justin Sullivan, Getty Images

by Julie Schmit, USA TODAY

by Julie Schmit, USA TODAY

An era of exceptionally affordable housing is fading in some parts of the U.S. as stagnant incomes collide with rising prices and interest rates.

The share of median household income devoted to home mortgage payments recently surpassed historical averages in six of 30 major housing markets, according to John Burns Real Estate Consulting.

Five of those are in California - San Francisco, Los Angeles, Orange County, San Jose and San Diego - and the sixth is Portland, Ore.

At the bottom of the housing downturn, those cities were more affordable than their historical averages dating to 1980, Burns' data show.

But home prices have risen rapidly in those cities as the housing recovery has taken hold.

Prices in Los Angeles and San Francisco were 21% higher in June than a year ago compared with the national average increase of almost 12%, according to CoreLogic.

Affordability remains high in most of the rest of the country.

In the second quarter, 69% of new and existing homes sold were affordable to families earning the U.S. median income of $64,400, according to the latest National Association of Home Builders/Wells Fargo Housing Opportunity Index.

That is down from almost 74% of homes sold in the first quarter and marked the lowest level for affordability in more than four years.

In 2006, at the height of the housing bubble, just 41% of homes sold were affordable for median income earners, the index shows.

Low interest rates have been a big driver of affordability.

Rates will stay near current levels - 4.4% for a 30-year, fixed-rate loan - for the next month, predicts Frank Nothaft, Freddie Mac's chief economist. But they'll crack 5% in mid-2014, he says.

If so, the cost of housing in 30 of 250 metropolitan areas will exceed historical averages for affordability, according to an analysis from market watcher Zillow.

Zillow's data shows a Honolulu resident earning the median income spent about 36% of it on monthly mortgage payments from 1985 to 2000. With 5% interest rates, rising house prices and flat incomes, they would spend 40%.

Those 30 markets include the Portland and the California ones identified by Burns, and also Denver; Ocean City, N.J.; Bellingham, Wash.; and Great Falls, Mont.

Zillow's calculation is based on median home values, a 30-year mortgage and a 20% down payment.

As the affordability gap widens, more consumers are likely to leave higher-cost areas in search of more affordable housing elsewhere, says Jed Kolko, Trulia economist.

Home prices may also flatten or decline in areas with low affordability, Zillow economist Svenja Gudell says.