The housing recovery that began in 2012 has lifted the overall market but left behind a broad swath of the middle class, threatening to create a generation of permanent renters and sowing economic anxiety and frustration for millions of Americans.

Home prices rose in 83% of the nation’s 178 major real-estate markets in the second quarter, according to figures released Wednesday by the National Association of Realtors. Overall prices are now just 2% below the peak reached in July 2006, according to S&P CoreLogic Case-Shiller...