TWO years after he vowed to “degrade and ultimately destroy” Islamic State (IS), Barack Obama is at last close to honouring his commitment. In the early hours of October 17th a long-planned military operation was launched to retake Mosul, Iraq’s second city. The battle will involve the Iraqi army, Kurdish soldiers, Shia militias, American special forces and the air power of a Western-led coalition. Mosul matters: it is the place from which the IS leader, Abu Bakr al-Baghdadi, declared his “caliphate”. The jihadists’ motto is “remain and expand”, but their state is fast retreating and shrinking.

There is little doubt that Mosul will fall (see article). But how it is taken will determine whether the battle marks a lasting victory against jihadism or another chapter in the unending agony of the Arab world. If Iraq is ever to attain stability, its leaders must find ways of assuaging the resentment of its once-dominant Sunni Arab minority, and giving it a political voice.

The meaning of Mosul

Done properly, the recapture of Mosul would not just liberate the million or more people living under the brutal rule of IS; in a sense, it would relieve the world. Unlike other jihadist movements, IS set itself up as a standing challenge to existing structures, an alternative theocratic polity that expunged borders, plumbed new depths of televised barbarity and acted as a magnet for its death-cult. Smashing IS will give the lie to its founding myth, that a new God-ordained world order is at hand. With Mosul lost, its fantasy will lie in ruins. No territory of any significance will remain to IS in Iraq; in Syria it will hold only the remote city of Raqqa and a few dusty towns.

That is not to say that the next weeks or months will be easy. No one knows how the battle for Mosul will unfold. Perhaps, as in Ramadi late last year, IS will stand and fight. That led to the destruction of much of the city and the flight of most of its population. Or perhaps, as in Fallujah in June, IS will simply run away. Most of its best fighters in Mosul, and almost all its leaders including Mr Baghdadi, have probably already gone.

The liberators must act with extreme care. Mosul must not become another Aleppo, which is being reduced to rubble by Syrian and Russian forces. Instead all action must be targeted, avoiding harm to civilians whenever possible and properly policing areas as they are taken from IS. More humanitarian assistance is needed if the world is to cater both for those who have started to flee and those who hunker down in the city.

Thereafter, it is important to avoid anything that looks like a Shia takeover of Mosul and the surrounding province of Nineveh. This is a majority Sunni Arab area, which should enjoy a large degree of autonomy. In turn, the rights of the many minority groups, among them Kurds, Christians, Yazidis and Turkomans, must also be protected. Above all, the many outsiders who would like a piece of Mosul for themselves—Kurdish forces, Shia militias, perhaps Turkey—must be kept out of the city. They would bring about only a violent free-for-all.

Though it might seem perverse, the wisest thing the would-be liberators could do would be to leave IS a safe way out of the city, eastward to Syria, to avoid a long fight to the death. The prize of taking Mosul as quickly and bloodlessly as possible is worth the cost of allowing an isolated Islamic Statelet to survive in eastern Syria a bit longer. Raqqa is a more vulnerable target. And it will be easier to induce IS recruits to give up the fight if Iraq shows it can woo back its Sunni population.

Having endured two insurgencies and 13 years of war, Iraq has a chance to rebuild itself. If it is not to be squandered, Mr Obama and his successor must not declare victory for a second time, rush for the exit—and leave Iraq to tear itself apart.