For others, the declines slowed somewhat.

Los Angeles County lost 90,000 residents in 2022, compared with a loss of 180,000 in 2021. Brooklyn’s population fell by 47,000, after falling by 82,000 in 2021.

Fulton County, which includes Atlanta, gained 12,000 residents after losing 7,000 the year before.

Many of the newcomers were drawn to big cities with more liberal immigration laws and longstanding immigrant enclaves.

Theodore Moore, vice president at the New York Immigration Coalition, greeted asylum seekers at the Port Authority Bus Terminal last summer, after they were bused north by Gov. Greg Abbott of Texas. Mr. Moore’s organization estimates that 50,000 migrants arrived in the New York metro area last year, from countries such as Venezuela, Colombia, Haiti and Cameroon, largely seeking asylum. The coalition estimates that another 20,000 Ukrainian refugees fled to New York.

Historically, immigration has been central to growth for the nation’s big cities, which have long experienced outflows of residents each year.

These more recent immigrants are less likely to have family ties in the New York area, and are struggling to find affordable housing and to gain work authorization, Mr. Moore said. As a result, many are working off the books, as farm hands, construction workers or street vendors, he noted, whether in the city or in rural regions of the state. And many are living in homeless shelters, which are at capacity. Mayor Eric Adams has moved to convert hotels, office buildings and other structures into temporary housing.