Peter Apps is Reuters global defence correspondent, currently on sabbatical as executive director of the Project for Study of the 21st Century (PS21). He tweets: @pete_apps

“Tell me how this ends,” U.S. Army General David Petraeus said in 2003, not long after the invasion of Iraq. What started as a private comment to a journalist later became his mantra.

It was a bold question, designed to cut through messy thinking from other officials as Washington tried to find its way out of the conflict. The result, of course, was much more complex than the U.S. military had hoped.

The most important answer to Petraeus’ question is that “it” wasn’t going to end. Rarely do wars have firm and tidy endings, an armistice or a final defeat like that of Germany in 1945 or Sri Lanka’s Tamil Tigers in 2009. Even if the killing stops, confrontations continue through politics and elsewhere.

Iraq was always going to be messy after the United States’ departure. Some of the Sunni groups who backed the Petraeus-led troop “surge” now fight with Islamic State. The attempted multiethnic Iraqi state began unraveling even before the United States left.

The histories of Somalia, India and elsewhere show the departure of a major imperial-style power is often followed by a battle for control between those who remain. The same is already happening in Afghanistan.

Still, fighting the Islamic State — both in Iraq and neighboring Syria — will not go on forever. How will it end? What can be done now?

Earlier this month, ex-National Security Council Iraq director Douglas Ollivant said there seem to be limits to how far Islamic State can spread. While the group has thrived in ethnic Sunni areas where government was weak — in Iraq and Syria, but also increasingly in Libya and elsewhere — when it butted up against other ethnicities or more functional states such as Jordan, Saudi Arabia and Turkey, it struggled.

Islamic State seems unlikely to take over the entire region — as some of the more apocalyptic analyses suggested last year. The challenge, therefore, is to limit its spread in a relatively limited space and then push it back.

The group has had some high-profile recent victories, most notably Ramadi in Iraq and Palmyra in Syria. Unlike the “old” al Qaeda, holding territory is central to the group’s reason for existing. If it cannot retain its territory, by its own terms it is a failure. Mounting hit-and-run attacks, even against the West, would not be enough. That’s why the Ramadi and Palmyra victories are so important, making up for much larger territorial losses elsewhere in Iraq.

No nation — with the possible exception of Iran — has a coherent strategy against Islamic State. The United States and the West have one strategy for Iraq, and slightly less than a strategy for Syria. But that’s not as stupid as it sounds. Defeating Islamic State in Iraq would destroy the group’s legitimacy, and undermine both its appeal to new recruits and its ability to intimidate those in the region.

Part of Islamic State’s stated aim is to dismantle the Iraq-Syria border and carve out a new territory across the region. Most experts say that letting either country fall apart is simply so messy that almost no one really wants it. Iraq’s primary ethnicities — Sunni, Shi’ite and Kurd — may not like each other, but the country cannot be redrawn into viable separate entities. Sunnis and Kurds both benefit from oil revenue from the Shi’ite south — and it’s not clear that a small Shi’ite state would be able to protect those resources.

A welcome sign along the Beirut-Damascus highway (Paul Keller).

Two years ago, some analysts suggested that Syria could unravel. But today that’s much less likely. More probable, diplomats quietly say, is a deal whereby someone in Damascus — probably not Bashar al-Assad — remains in control of a country with the same current borders. Few expect that to be quick.

That means that the question of how the Islamic State war ends is really a question about what a viable post-war Iraq and Syria might look like.

The problem now, says former UK Director Special Forces Graeme Lamb — an adviser to U.S. commanders like Petraeus and Stanley McChrystal — is that the Shi’ite-run Iraqi government is so dependent on Shi’ite militia and Iranian support that many Sunni now fear the departure of Islamic State. They suspect it may simply be followed by brutal reprisals and savage ethnic domination.

Changing the narrative, Lamb believes, ultimately comes down to creating a roadmap to a future Iraq in which those groups feel much safer. If Sunni groups see that as a potential reality, they might be persuaded to turn on Islamic State, just as some did against al Qaeda during the surge. But that shift requires a very different Iraqi political environment than exists today.

During the 2007-9 “surge,” local Sunni leaders were won over by a combination of promised political reform and their growing frustration with foreign al Qaeda fighters. Repeating that may be tough. But that does not make it impossible.

In Syria, Western governments lack the kind of understanding they gradually obtained in Iraq.

Most Western and other officials increasingly believe the high-level deal will be done elsewhere, probably between Russia and the West and regional powers. That will probably mean easing Assad aside somehow, perhaps with a deal for immunity from prosecution.

To win and preserve its caliphate, Islamic State faces huge problems. The history of non-state groups trying to carve out larger amounts of territory in the face of strong government opposition is not a happy one. The Tamil Tigers failed last decade. Nigeria’s breakaway Biafra failed in the 1960s. The South didn’t manage it in the American Civil War.

There are, of course, a handful of exceptions: Kosovo, Eritrea, South Sudan. But to be recognized and established, they required a degree of international acceptance and backing that it is almost impossible to imagine for Islamic State.

The mismatch between a non-state group and its government is enormous. The latter can call on international financial aid, buy weapons, or rely on intelligence support, advice and equipment from other governments. Islamic State might be rich in terms of militant groups, but it is already feeling the squeeze.

Kurdish protest against ISIS in London, October 2014 (Alan Denney).

In May, Israeli intelligence told foreign reporters that total Islamic State revenues had dropped from $65 million a month in the middle of last year to some $20 million now. Oil income in particular had fallen, even as taxes and ransoms rose — both potentially helping alienate the populations now under Islamic State control.

Coalition airstrikes are also having an effect, as will new weapons deliveries. A lack of anti-tank weapons, experts say, was a major factor in the loss of Ramadi. In the Syrian Kurdish town of Kobane, the combination of the two held Islamic State back and denied the group a crucial propaganda victory.

Extra U.S. and allied advisers could also make a difference — although too many might simply be viewed as a renewed foreign occupation.

To be beaten, however, Islamic State has to look as though it is losing. It isn’t there yet.