IRVINE, Calif. — This was the state that embodied the middle-class American dream: Move west, acquire a small slice of property, perhaps with a palm tree or two.

For decades, comfortable suburbs like this one just south of Los Angeles boomed with new housing tracts designed to attract the latest arrivals. When space started to come at a premium, developers moved inland, building more homes for people who could not afford the more expensive coastal areas.

But now, cities across the state are grappling with a dwindling stock of housing that can be considered affordable for anyone but the wealthiest. In much of the state, a two-bedroom apartment or home is virtually impossible to acquire with anything less than a six-figure salary.

“It’s hard to imagine how all of California doesn’t become like New York City and San Francisco, where you have very rich people and poor people but nothing in between,” said Richard K. Green, an economist and director of the Lusk Center for Real Estate at the University of Southern California. “That’s socially unhealthy and unsustainable, but it’s where we are going right now — affordability is its worst ever, and we’re seeing a hollowing-out of the middle class here.”