SCENES of jubilation greeted Kurdish-led forces when they routed Islamic State fighters from the city of Manbij in northern Syria last August. In the streets, women set fire to the long black veils the jihadists had forced them to wear since they seized the city in January 2014. Men shaved off the beards they had been obliged to grow. One old woman was photographed puffing merrily on a cigarette, an activity punishable with prison in the “caliphate”. For many, however, the giddy joy of liberation soon gave way to tragedy.

“The first explosion killed our neighbour and his sister-in-law when they entered their house,” said Ali Hussain Omari, a former fighter from the city. “Three days later another mine killed my cousin. His 11-year-old daughter’s leg was amputated and their house was destroyed. A week later another mine in an olive tree exploded. My neighbour lost his leg.”

The amount of land that IS controls is shrinking quickly in both Iraq and Syria. But the group can still kill and maim, even in areas it no longer occupies. Within ten days of Manbij’s liberation, booby-traps and mines planted by the retreating jihadists had killed 29 people, according to the Syrian Institute for Justice, an NGO.

The story is similar in other newly liberated towns and villages across Iraq and Syria. As they retreat, the jihadists have booby-trapped homes, schools, hospitals and mosques. They have laced vast tracts of land with improvised landmines, creating minefields that extend for dozens of kilometres. The territory once occupied by IS is now one of the most heavily mined regions on earth. The clean-up will cost millions and last decades.

In villages once occupied by IS, civilians desperate to restart their lives are returning to find their homes, streets and fields riddled with bombs. IS has rigged everyday objects to trigger explosions powerful enough to bring down buildings—loaves of bread, teapots, fridges, vacuum cleaners and computers have all been rigged with explosives. Bomb-disposal teams have found dolls fitted with motion sensors, lights that explode when switched on and water taps that set off charges when opened. Others are less sophisticated: a hand-grenade, pin removed, placed in a glass balanced on top of a door.

Among the hardest triggers to spot are tiny “crush-wire” devices—lengths of copper wire covered in dirt or plaster and scattered across streets, often disguised to look like small stones. Dead bodies have also been rigged to explode. “How do you warn people about this? How do you tell them not to go to schools or hospitals, not to pick up rocks or tread on stones? Not to move kettles or sit down on sofas?” says Saeed Eido of the Syrian Institute for Justice.

Booby-trapped homes are only part of the problem. To defend its territory, IS has planted most of its mines in thick belts that ring hundreds of villages and towns on both sides of the border. In a single village south-east of Mosul, clearance teams with the Mines Advisory Group (MAG), a British NGO, have removed more than 1,000 mines since October. The village and surrounding land are still not fully cleared. Experts estimate that, across Iraq and Syria, IS may have planted more than 100,000 landmines—the largest arsenal of improvised mines they have ever seen.

The wars that raged during the final quarter of the 20th century brought a surge in the use of landmines. By the mid-1990s the weapons were killing roughly 26,000 people every year. That number dropped sharply after the Ottawa Treaty, which banned the use of landmines, came into force in 1999 (see chart). But IS has reversed the trend. Casualties are rising once again, even as funding for mine clearance is at its lowest for years. “We are witnessing a new landmine emergency on a scale not seen since the historic treaty to ban landmines was agreed 20 years ago,” says Jane Cocking, MAG’s chief executive.