The problems in Afghanistan often feel intractable, like a knot of countless ropes bound together. Every time a strand is pulled, another part of the knot tightens up. Currently, the Taliban refuse to have talks with the Afghan government, which they label a puppet regime; the Kabul government insists that any power-sharing agreement allow limited numbers of Western troops to remain; the Pakistanis, who have long sheltered Taliban leaders, are unwilling to fully encourage a peace settlement; the United States and its NATO partners are sick of war and want out; the Russians play a complex double game, sometimes encouraging the Taliban and other times working with the government; and India and China covet the rare-earth metals and other minerals under the dry soil — perhaps $2 trillion worth.

But there are also some distinct signs of progress, due largely to Zalmay Khalilzad, who last year took over as the U.S. special representative to the reconciliation process. I know Zal well, and as the saying goes, if he didn’t exist we’d have to invent him. He was born in Afghanistan, received a Ph.D. from the University of Chicago, and has served as a U.S. ambassador three times (to the United Nations, Afghanistan and Iraq). Khalilzad is a highly creative thinker and diplomat.

He has moved the situation to a serious level of dialog, through a variety of techniques including a shifting cast of characters at the talks, keeping the Taliban and the Afghan government from having to sit directly with each other, moving the location to the Qatar, Pakistan and other “neutral” sites, engaging Russia and Pakistan effectively, and keeping strategic communications flowing.

Partly, these gains stem from war fatigue on both sides. When I was supreme allied commander overseeing 150,000 U.S. and coalition troops in the field, we made good progress pushing the Taliban out of all urban areas, educating the youth (including girls for the first time since the Taliban rule), helping the dismal economy start to grow, and extending life expectancy. With now about 14,000 U.S. troops (and 7,000 additional from coalition members), we have reduced our military footprint more than 80 percent with a commensurate drop in casualties.

On the Taliban side, a new generation of leaders seems increasingly tired of the conflict as well. They have indicated a willingness to talk about allowing a power-sharing arrangement, permitting women to hold on to some of their hard-won rights, and perhaps creating a system of local self-government that would allow some flexibility in their previously rigid adherence to Shariah law. Perhaps most important, the Pakistanis seem willing to consider an Afghan government not dominated solely by their Taliban clients.

The Taliban have also made recent gains on the ground, and Afghan Security Force casualties have risen to unacceptable levels. President Ashraf Ghani understands that reaching a deal is urgent.

All this is a sea change, giving a better than even chance to land this diplomatically with a settlement that allows Taliban participation in fair elections. Getting there will require all sides to back off some of their hard-line positions. A two-pronged approach can help U.S. engineer that outcome: let the Afghan government know that patience is running out, and keep the military pressure on the Taliban.

The U.S. experience in Vietnam is instructive: while the vast majority of troops left in 1972, the South Vietnamese held on for three more years because the U.S. continued to finance their military. Saigon fell finally in 1975 when the Congress slashed the funding. Letting the Taliban know that the U.S. learned from that experience and plans to keep money flowing to the Afghan military and to maintain a relatively small counterterrorism force to face al-Qaida and the Islamic State, would keep the pressure on them as well.

Afghanistan has long been called the “Graveyard of Empires.” That sobriquet usually refers to the British Raj of the 19th century and the failed Soviet experience in the 20th century. But the first European to conquer that troublesome land and hold power — at least for a time — did it more than two millenniums earlier: Alexander the Great. In his marvelous novel about that ultimately failed conquest, “The Afghan Campaign,” Steven Pressfield provides a vivid portrait of the young king, his military victories and eventual political defeat.

Before his march to Asia, the legend goes, Alexander was confronted with an intricately tied, seemingly impossible tangle of rope in the city of Gordius in modern-day Turkey. It was said that whoever could untie the knot would one day conquer all of Asia. The impetuous young king tried his hand and unraveling it, was instantly frustrated, and then simply took out his sword and cut the bonds. He did go on to conquer Egypt and much of Asia, including Afghanistan.

Let’s hope Khalilzad is just the diplomat to cut today’s Gordian knot. The key will be persuading both sides to accept a compromise that is far from perfect for either, but allows Afghanistan to move forward.

James Stavridis, a Bloomberg Opinion columnist, is a retired U.S. Navy admiral and former military commander of NATO.