Lin Huiqing moved to Beijing to look for work when his children were still in diapers.

For the last 18 years, he has seen his family just once a year, the rest spent doing the hard labour most Beijingers would prefer to avoid.

The 50-year-old is one of hundreds of millions of migrants who moved from the countryside to the cities, a colossal demographic shift that made China’s ascent possible.

But last month Lin was evicted from the village where he lived on the capital’s outskirts, another victim of a citywide demolition plan to limit Beijing’s population to 23 million by 2020 – a target that could come at the cost of its economy.

“If I go home, I have no way to support my wife and kids,” Lin said.

Lin, like other migrant workers, fuelled his nation’s dramatic economic rise, toiling in jobs far from home, but he and others are now finding themselves increasingly unwelcome as authorities try to cap the population explosions in key cities.

According to the Communist Party mouthpiece People’s Daily, the city plans to demolish 40 million square metres of “illegal” structures. Many are the homes and shops of low-income migrants like Lin.

When he first arrived in Beijing, Lin and his friends pooled their money and took out loans to buy delivery trucks.

He made a living hauling the wares of small-scale shopkeepers and traders, but the moving business has taken a hit as the city condemns buildings en masse, evicting tens of thousands into the winter cold.

“Our customers are commoners like us,” he said. “With their small businesses shut down, there’s no stock for us to move. We’re basically unemployed now.”

Authorities say the campaign, which kicked into high gear after a fire in an illegal structure killed 19 in November, is needed to clean the city up once and for all.

But it is also removing vibrant chunks of Beijing’s economy, such as retail and small-scale manufacturing, and throwing into chaos other sectors like delivery, the bedrock of the booming e-commerce trade.

Relegated to the periphery, migrants have kept China’s economy humming, handling the difficult, dirty and sometimes dangerous work that the city’s permanent residents will not do.

Urban industries like construction, domestic work and sanitation are almost completely staffed by migrants.

Eli Friedman, associate professor of international and comparative labour at Cornell University, said China’s biggest cities “simply cannot function without migrant workers”.

“If every non-local were to actually be removed from cities like Beijing, Shanghai, and Guangzhou, these economic engines for the whole country would completely collapse,” he said.

But that is exactly what is happening, according to Li Ning, one of the 60,000 delivery drivers who criss-cross Beijing’s streets.

Li was recently evicted from a village on the city’s outskirts, forcing him into a flat where the rent quadrupled.

Then authorities came for his delivery company’s warehouse, forcing staff to sort packages on the pavement and sending his income plummeting.

“In Beijing all the migrants are leaving. We can’t make it here any more,” he said, adding he plans to leave for good the Lunar New Year next month.

Another delivery franchise owner surnamed Wang said she would “give up” if authorities knocked down her warehouse, which they marked in black paint with the character “chai” – meaning “demolish” – last month.

She had just moved in December 1, after she had to close two other delivery hubs this year, forcing her to cut her work force from 240 couriers to 60.

“There’s no stability. I don’t know what I’ll be facing tomorrow,” she said.

The demolitions have also hit Beijing’s retail sector, destroying once-affordable family-run shops and pushing consumers online or into high-end malls.

Two years ago, Ge Guoxiang moved with his wife from their home province of Jiangsu to take over his brother’s textiles stall.

It had thrived for over 20 years in Beijing’s Tuanjiehu Tianyu market. But three months ago, they received notice that authorities would close the market.

Dozens of small-scale community markets have been forced to shut down this year – including the Beijing Zoo market, where hundreds of merchants organised rare street protests against the evictions.

Officials said they had designated certain areas in the neighbouring Hebei province where merchants could move their businesses to.

But Ge is unconvinced.

“It takes years for businesses like ours to build up clientele. Now we have to start over,” he said.

“Our clients are mostly older people who don’t know how to shop online. Where will they go?”