Beijing is a cultural, technological and commercial capital as well as a political one, and the tenements on its outskirts are home to tens of thousands of hopeful young college graduates who have moved here seeking better jobs and better lives.

These job seekers are treated as migrants in their own capital, because China’s biggest cities are fortresses of official privilege, especially Beijing. The government gives inhabitants who hold permanent residence papers, called hukou, more generous access to housing, schools and health care. But migrants must pay more for many services, and many live on the edges of Beijing, where rents are lower.

Now whole swaths of these neighborhoods have been emptied out and in many cases reduced to rubble as the authorities condemn buildings as unsafe or illegal and order migrants to leave.

That has ignited debate about how Beijing can function without the blue-collar migrants who serve as its cooks, cleaners and vendors, but there are also worries the campaign might harm the city’s fast-growing tech sector, which employs armies of migrants who work for relatively low pay.