– The high cost of housing seemed to sap Americans’ taste for coastal cities last year as cities in Texas and Arizona gained more population than New York City or Los Angeles for the first time in a decade, according to new census population estimates.

“What started as a promising decade for big cities is starting to crumble a little bit for them,” said William Frey, a demographer at the Brookings Institution, in an e-mail. “The Great Recession put the brakes on dispersal to small metro areas, suburbs and the Sun Belt; but those trends are beginning to resume again.”

San Antonio’s population grew by 24,200 between 2016 and 2017, the largest gain among cities, with Phoenix not far behind at 24,000.

It was the first time since 2007 that New York City did not lead the pack in population growth.

The last time a Texas city had the largest population surge was in 2006, when Houston — a major destination for Katrina evacuees — added about 43,000 people.

One factor, based on earlier census releases, is that more people have been moving out of New York City and Los Angeles, making it harder for those cities to maintain population growth just through births and immigration. By contrast, people continue to move into more affordable cities like San Antonio and Phoenix.

New York City’s overall population grew slightly between 2016 and 2017, but 143,000 more people moved out than moved in. During the same period, Phoenix’s Maricopa County attracted more than 39,000 new residents and San Antonio’s Bexar County added 10,000.

The high and rising cost of living in coastal metropolises seems to be playing a role. The typical Los Angeles or New York City homeowner, for example, spends close to 30 percent of her income on mortgage and taxes, compared with about 22 percent in San Antonio and Phoenix.

Population growth slowed in most cities of more than a million people, except San Antonio and Philadelphia.

Opportunity as well as affordability may be spreading to smaller towns, recent county population data show. Cities with 20,000 to 30,000 residents saw increasing rates of population growth for the third straight year, adding 104,000 people as a group from 2016 to 2017.