What lessons can we take from the Islamic State’s defeat in Mosul and its coming eviction from Raqqa? The collapse of the caliphate tells us that the United States can succeed militarily in the Middle East if — and probably only if — it works with local forces who are prepared to do the fighting and dying.

Where the massive U.S. ground campaigns in Iraq and Afghanistan over the past decade and a half became expensive exercises in frustration, the war against the Islamic State has been far less costly in money and American lives — and also more successful. Amazingly, over the past three years, just five Americans have been killed in action in Syria and Iraq, according to the U.S. military.

The overall human toll has been horrific, even if Americans haven’t been paying the price. A triumphal Iraqi Prime Minister Haider al-Abadi proclaimed victory in Mosul on Monday, but pictures of the city showed a devastated wasteland of pulverized buildings. We may never know how many thousands of civilians lie under the rubble.

Because the U.S. footprint and casualty levels have been so modest, to Americans this war has mostly been out of sight, out of mind. But it’s worth examining how the strategy has worked militarily — and to recognize the lack of any corresponding political strategy, which may well cause problems down the road.

The American campaign has been built around Special Operations forces. The SOF slogan has been that the battle must be waged “by, with and through” local partners. That has meant training, equipping and advising Iraqi and Syrian soldiers — then providing them with air support that has relentlessly pounded the enemy.

The most brutally efficient part of the campaign has been the secret “capture or kill” strikes by the United States and some of its partners. In simple terms, when the United States has had actionable intelligence about a terrorist operative, it has tried to take that person off the battlefield.

The marriage of local ground forces with U.S. drones, warplanes and intelligence has been potent. Linda Robinson, a Rand Corp. analyst who spent weeks observing the fight this spring in Iraq and Syria, wrote in a recent blog post that the United States has found a “new way of warfighting.”

Credit for this innovative campaign goes to the U.S. military, which became increasingly confident after a slow start; to President Barack Obama, who sent thousands of U.S. troops to Iraq and Syria despite public wariness; and to President Trump, who delegated decisions to the military in ways that accelerated the campaign.

The surprise has been how motivated and disciplined the Iraqi and Syrian forces have been. They’ve fought bravely, taking significant casualties. And for the most part, they have cooperated across sectarian lines.

In Iraq, the United States has relied on two battle-hardened forces: the Iraqi army’s Counter Terrorism Service and the Kurdish peshmerga. The two cooperate on the battlefield (even as their political leaders continue to bicker). Meanwhile, Iraq’s Shiite militias, which analysts feared would undermine the fight against the Sunni extremists, haven’t played that spoiler role.

In Syria, America’s decisive ally has been the Kurdish militia known as the YPG. This partnership began almost by accident back in 2014, when the marauding Islamic State was on the verge of capturing Kobani in northern Syria. Iraqi Kurds from the Patriotic Union of Kurdistan militia touted the Syrian YPG to their American advisers, and an improvised system of spotting, targeting and air assault evolved. The Americans were astonished by the determination of the Kurds, and a warriors’ kinship developed.

The Syrian Kurds were an awkward ally politically, because Turkey regards them (probably rightly) as an offshoot of the terrorist PKK. But as U.S. Central Command commander Gen. Joseph Votel told me at a training base inside Syria a year ago, “We have to go with what we’ve got” in Syria, which meant the Kurdish-led force.

This sort of improvised approach has characterized the U.S. effort since 2014. Rather than build the ideal force on a U.S. model, commanders adapted. Political problems — bitter Turkish opposition, Iraqi Kurdish ambitions for independence, incoherent political strategy for Syria — were put on the shelf for later. The military strategy has been built on political quicksand, but it’s still standing.

In 2012, the CIA conducted a study that argued that American support for such local forces had rarely worked. But sources say that agency analysts had an important caveat: In the U.S. interventions that were successful, the United States had operated closely with its partners on the battlefield. This finding seems to have been reinforced in Syria and Iraq.

Read more from David Ignatius’s archive, follow him on Twitter or subscribe to his updates on Facebook.