IN A wealthy neighbourhood in Tehran, Iran’s capital, a 12-year-old boy in a tatty red shell-suit patrols neat cul-de-sacs in search of bins. Like thousands of illegal Afghan refugees in Iran, he rummages daily from dusk till dawn for plastic to sell. “If Iran didn’t exist, neither would I,” says Zalmai, dropping a big sack. “I don’t want to go back.” He left his parents in Herat, in west Afghanistan, three years ago and has never been to school. He makes 150,000 rials a day ($4.20) from selling plastic.

Thirty years of war in Afghanistan have left Iran with perhaps the largest urban refugee population in the world. More than 1m Afghans are registered as refugees in the Islamic Republic, which is also home to another 1.5m-plus illegal Afghan migrants. But a mixture of Iran’s worsening economic malaise and its government’s policies has prompted an exodus of Afghans back home or westward to Turkey and Greece. Some 200,000 of them are reckoned to have gone back in the past seven months; 5.7m—15% of Afghanistan’s population—have returned in the past ten years, most of them during the presidency of Mahmoud Ahmadinejad that began in 2005.

Afghan migration to Iran is as old as the Islamic Republic. During the Soviet invasion of 1979, hundreds of thousands of Afghans fled to Iran, though it was itself in the throes of revolution. For a decade they were ignored by the government, denied dignified work and often derided in the press as violent criminals and drug dealers. During the “construction period” of the 1990s under Akbar Hashemi Rafsanjani’s presidency, the government sought to naturalise them. Most were working in construction. But under Mr Ahmadinejad things have got harder. As the economy falters under foreign sanctions, the government is now encouraging both illegal and legal refugees to go home. The Bureau for Aliens and Foreign Immigrants’ Affairs has stepped up random inspections of building firms and factories, threatening to shut down those that employ undocumented workers. It also announced that marriages between illegal migrants and Iranians would go unrecognised and that illegal immigrants could not now qualify for refugee status. Children of an illegal immigrant have no legal status, barring them from education and health care.

Tehran’s popular technocrat mayor, Muhammad Qalibaf, a presidential hopeful, has introduced a municipal service to compete with illegal workers such as Zalmai in the lucrative recycling market. And some jobs in pest-control and sewer-clearance have been automated, filling the gap created by leaving Afghans. Hamid, a 43-year-old legal refugee, has been living in Iran for over a decade. “They treat us very badly,” he says, visibly upset. “We don’t have the advantages of Iranians. We can’t have mobile phones or cars and they make the paperwork more complicated and expensive every year.” Referring to illegal refugees, he says “everything is about money. The police look for their houses, steal savings and then deport them.”