As Iraqi and Kurdish forces advance towards Mosul, they are coming across booby-trapped bunkers rigged with explosives in the villages abandoned by Islamic State (IS). The network of tunnels suggests the extremists had been increasingly forced to operate underground by a punishing air campaign and mounting territorial losses.

These defences suggest the advance into Mosul will be slow and dangerous. When they finally reach Mosul, Patrick Martin of the Institute for the Study of War in Washington said they should expect to see similar complex defences, but on a much greater scale. "They're making sure that whenever the operation to retake the city commences it will be extremely difficult for the security forces to do so," Martin said, adding that while there are reports of some IS fighters fleeing Mosul, the group has also displayed a willingness to defend the city by mobilising car bombs, suicide bombers and building trenches.

This part of northern Iraq is among the most diverse in the country, with many ethnic and religious groups fearful of revenge attacks and worried about the balance of power once IS fighters are chased away. In an announcement that could alarm some Sunni civilians in the path of the fighting, a powerful Shia paramilitary force said it would support the Iraqi army's offensive by helping secure a town located on one of the main routes out of Mosul.

The Popular Mobilisation Force (PMF), a coalition of mostly Iranian-trained militias, said it will back government forces advancing towards Tal Afar, about 55km west of Mosul. The PMF, which includes thousands of battle-hardened fighters with powerful political allies in Baghdad, has been accused of carrying out killings and kidnappings in other areas freed from IS, although they deny such abuse is pervasive. Iraqi officials want to keep them off the main battlefields in Mosul to avoid alarming Sunni Muslim residents.

Taking Tal Afar would cut off the escape route for militants trying to head into neighbouring Syria, but it could also hamper the escape of civilians from Mosul.