It’s time to get out of Afghanistan. Here’s how.

Donald Trump campaigned as someone who wanted to get America out of the Middle East. But he also cast himself as a tough guy, and his initial instincts in office were to show force — added troops, more aggressive rules of engagement, bigger bombs — in America’s war zones. “These killers need to know they have nowhere to hide,” he said when announcing a troop surge in Afghanistan.

Now we get reports that the Trump administration is searching for a negotiated settlement with the Taliban. However meandering the road, the administration is on the right path. But it is a very difficult one to navigate.

The war in Afghanistan, which began in 2001, is already the longest military operation in U.S. history. Our involvement there cannot be compared to the U.S. military presence in Germany, Japan or South Korea. The permanent bases in those countries were designed to deter external aggression (from North Korea, for example). In Afghanistan, the United States is engaged in a military effort to ensure that the Kabul government is not overthrown by an insurgency — more comparable to a neocolonial force supporting a friendly local ruler.

For this reason, both the Bush and Obama administrations sought a way out of Afghanistan. But they found it difficult to just leave and declare victory. First, the simple reality was that the Taliban inexorably advanced as U.S. troops withdrew, putting the democratically elected Kabul government — which is friendly to the United States — in mortal peril. Second, as America stepped back, it was clear that other countries — regional powers like India, China, Iran and Russia — would fill the vacuum. And finally, with all its factions, there was no single Taliban with which to negotiate.

And yet, the United States cannot stay in Afghanistan forever. Our presence distorts U.S. foreign policy, tying significant resources to an area of limited national interest. It also creates an inevitable dependency for the fragile Afghan government. The United States is spending $45 billion a year on security and economic aid for Afghanistan. That’s more than double Afghanistan’s entire gross domestic product.

So what is the right exit strategy? In an essay in Foreign Affairs, preeminent scholar Barnett Rubin argues that any political settlement will be extremely difficult and will require negotiations with both the Taliban and regional powers.

The central reality that Washington must come to grips with is that it will have to allow the Taliban a more formal role in power-sharing. In a comprehensive 2014 report, a pair of Rand scholars showed that, historically, the key to ending protracted insurgencies has usually been to accommodate the insurgents within the new political order.

In a conversation with me, Rubin offered some guidelines for a possible pathway to a political settlement. Don’t let the U.S. military be the lead negotiators, he cautioned, because its stark message to the insurgents has been “reconcile or die,” as the top U.S. commander in Afghanistan, Gen. John W. Nicholson Jr., has made clear. “This is not the way to start a dialogue with people whose entire culture is organized around personal and collective honor, which, by the way, is a much bigger factor in this war than so-called extremist Islam,” Rubin said.

He added that it’s obvious this conflict has no purely military solution. If there were, the war wouldn’t be in its 17th year. He pointed out that even maintaining the current military involvement requires better political ties with Afghanistan’s neighbors. “Look at a map,” Rubin said. “Afghanistan is landlocked. America needs supply routes.” The three countries that could help with access are Pakistan, Russia and Iran — and we have bad relations with all three.

Rubin’s chief advice is to work hard at the diplomacy. Recognize that other countries have an interest in Afghanistan and engage them. A successful outcome is entirely dependent upon involvement from India, Pakistan, China, Russia and Iran. Rubin suggests appointing a special envoy, ideally conferred with broader legitimacy under the authority of the United Nations.

But whatever the process, crucially, Washington will have to decide whether it is willing to get serious about Afghanistan. It cannot, for example, keep fantasizing about overthrowing the Iranian regime while simply hoping for a settlement in Afghanistan. Iran and Pakistan have the means to ensure that Afghanistan stays unstable forever. The largest regional issue is for Washington to decide how much to involve India, which would shift the strategic landscape altogether.

This is the difficult, painstaking work of diplomacy that the Trump administration has tried to ignore, demean and defund. But if the president actually wants to extricate America from its unending wars, it’s the only way out.

(c) 2018, Washington Post Writers Group