This month, for the first time, the U.S. armed forces are recruiting young men and women who weren’t yet born when the invasion of Afghanistan took place.

The war has been going on for 17 years now (17-year-olds can enlist with parental consent), making it the longest war in American history. Yet we are no closer than we have ever been to accomplishing our objectives, in part because those objectives have been so sketchily, inconsistently, and unrealistically defined.

In fact, the Taliban is gaining strength; other jihadist groups, including ISIS and a revivified al-Qaida, are joining the fight (against the Afghan government, Western forces, and the Taliban); the Afghan Army is suffering casualties at an alarming rate; the chaos is spiraling to unsustainable levels.

Just Thursday, a gunman wearing an Afghan Army uniform opened fire at a security meeting in a government compound, killing two top provincial governors, wounding three U.S. officers, and just missing the U.S. commander in Afghanistan, Gen. Austin “Scott” Miller, who was the apparent target of the attack.

There is no road to victory in sight. And there probably never was one.

It is worth recalling how we got to this point. One month after the terrorist attacks of Sept. 11, 2001, a combination of CIA commandos, U.S. special forces, and Afghan guerrillas—backed by brand-new smart bombs—overthrew the Taliban government, which had given sanctuary to Osama Bin Laden and his al-Qaida terrorist group. That December, at a conference in Bonn, Germany, Western leaders installed Hamid Karzai, an Afghan who had spent years in exile, as the interim leader of a Western-style centralized government in Kabul.

That may have been the original sin in our policy. Afghanistan—a mountainous, sparsely populated, largely illiterate country, where power has long resided with local or regional tribesmen or warlords—seems inherently ill-suited for that form of government.

The second, and ultimately larger sin occurred shortly after the Taliban’s ouster, when President George W. Bush and Secretary of Defense Donald Rumsfeld declared that the war was won and done—and refocused their attention, and resources, on the impending invasion of Iraq.

As it turned out, Taliban and al-Qaida forces hadn’t quite left the premises. Meanwhile, the Karzai government had a predictably hard time securing its hold and providing basic services. The loyalty of the people was up for grabs, as were large chunks of territory, and the Islamist militias contested them.

In 2006, the U.S. turned over its ever-dwindling military operation to NATO—whose leaders were looking to take on a new kind of mission in the post–Cold War era and thought Afghanistan might be a testing ground. These allies thought they were signing up as “peacekeepers.” Yet when they sent their troops out on patrol, the Taliban came out to fight. Suddenly, each country in the coalition insisted on “waivers,” dozens of them, all told. One country would send air support but not ground troops, another would fight on the defense but not the offense—resulting in a fragmented, feckless command structure. A small contingent of U.S. forces, fighting al-Qaida militias on the eastern border with Pakistan, stayed independent of NATO and killed lots of terrorists, but this had little effect on the shape and security of Afghanistan.

During the 2008 presidential campaign, Barack Obama depicted Iraq as the bad war and Afghanistan as the lamentably ignored good war, and pledged to pull out of the former while doing more in the latter. In his first months in office, he held 10 meetings with his National Security Council to decide on an Afghan war policy. Critics accused him of indecisiveness, but a bigger factor was bureaucratic incoherence. At one meeting, an official suggested that the U.S. support effective provincial governors rather than the central apparatus in Kabul. Obama asked which provinces could best use the support. No one knew, so he scheduled another meeting and told the officials to find out the answer by then.

The big debate in those meetings was between those who argued that we should merely supply and train the Afghan Army, using U.S. forces only to fight al-Qaida terrorists on the Pakistan border, and those who argued that we should wage an intense counterinsurgency campaign. COIN (as the term was abbreviated) would require a larger U.S. military presence and a huge aid-and-advisory effort to help Karzai run an effective government. The idea was to win the hearts and minds of the Afghan people by providing them with security and services. Then, support for the Taliban would melt away.

All of Obama’s military advisers recommended a COIN strategy, which they estimated would require an additional 40,000 U.S. troops. Vice President Joe Biden and Secretary of Defense Robert Gates were the main advocates of the limited approach, which would take only 10,000 more troops. Then Gates changed his mind, persuaded by the COIN side’s arguments, and the debate was over.

It is likely that no U.S. military campaign would have much chance of success, and this has been clear for nearly a decade.

However, in a final meeting in December 2009, just with Gates and the top officers, Obama asked whether they were confident that, with the COIN strategy and the extra troops, they could help the Afghan Army control more than half the provinces within 18 months. If you’re not confident, he said, I’ll go with Biden’s approach. If you are confident, keep in mind, this is all you’re going to get. If the experiment doesn’t work after 18 months, I’ll stop the strategy and withdraw the surge troops. Everyone present said they were confident—though, in fact, most of them were not. Historically, COIN campaigns take years to achieve their goals, if they work at all, but the advisers figured that they’d at least make enough progress after 18 months to convince Obama to give them a few more brigades.

Exactly 18 months later, Obama announced that he was ending COIN and pulling out the surge troops. Publicly he said that he was doing so because they’d succeeded, citing the killing of Bin Laden in Pakistan (an operation that had no relation whatsoever to the COIN campaign in Afghanistan). But his advisers knew—and were shocked—that he was merely making good on his promise: He wasn’t giving them the few more brigades that they’d requested.

Obama reverted basically to the Biden plan. Shortly before leaving office, he decided to keep 8,000 troops in Afghanistan, as a counterterrorism force for the region, without any illusions that it would help build Afghanistan itself into a more stable or prosperous country.

Critics say Obama made a strategic error by publicly announcing when he planned to withdraw the surge troops; this put the Taliban on notice that they could simply wait out the United States, then step up the fight after we’d gone. Theoretically, the critics had a point. But in fact, the Taliban put up a very fierce fight during those 18 months; they showed no sign of hanging back.

By contrast, President Donald Trump announced in August 2017 that he was sending a few thousand more troops to Afghanistan and imposed no timetable for their withdrawal; they might stay there forever. This has had no effect on the Taliban’s behavior either.

It is likely that no U.S. military campaign—whether based on COIN, counterterrorism, or some other principle—would have much chance of success, and this has been clear for nearly a decade. Early on in the Obama phase of the war, Adm. Mike Mullen, chairman of the Joint Chiefs of Staff, told the Senate Armed Services Committee that the main obstacle was “clearly the lack of legitimacy of the government.” Sen. Lindsey Graham asked, “We could send a million troops and that wouldn’t restore legitimacy in the government?” Mullen answered, “That is correct.”

Corruption has long been endemic in Afghanistan. The centralized government, with presidentially appointed governors relying on bribery and patronage, intensified the problem. The flood of money swooshing around the country in the form of U.S. aid—billions of dollars, worth more than Afghanistan’s GDP—only exacerbated the problem. In some cases, ineffectual governors paid the Taliban not to attack their provinces—meaning U.S. aid was subsidizing the Taliban.

Mullen and Gen. David Petraeus, when he was a commander of U.S. forces in Afghanistan, frequently said that the war could not be won by military force alone, that there would have to be a political settlement. They also argued that the U.S., NATO, and Afghan forces needed to rack up a series of tactical successes, in order to negotiate from a “position of strength.” The problem was that these big successes were never achieved, nor were any preparations made for peace talks, in the event of some moment of dominance.

The main problem was that the U.S. officers and officials running Afghan policy didn’t know much about Afghanistan. On at least one occasion, they opened tentative peace talks with somebody claiming to be a Taliban leader who wasn’t one at all. They launched drone strikes on native Afghan Taliban militias, who were fighting for myriad motives, making no distinction between them and foreign jihadists—much less exploring ways to drive a wedge between the factions.

During the height of the COIN period, they tried to help the Afghan government provide basic services to the population. But David Kilcullen, a former infantry soldier and COIN scholar who advised U.S. commanders in Afghanistan, says they would have done better helping provide justice. In areas where they are in control, the Taliban has set up its own courts, highway checkpoints, and recruitment centers—all of which, Kilcullen says, are viewed by local people as fairer and less corrupt than those operated by the Afghan government.

When Trump came into office, he was inclined to pull the remaining 8,000 U.S. troops out of Afghanistan. He wound up adding another 5,000 (though without announcing the precise number). His national security adviser, H.R. McMaster, helped clinch the deal by showing him a photo from the 1970s of some women in Kabul wearing miniskirts—as if that proved Afghanistan could once again be a normal country. Secretary of Defense James Mattis also briefed him on what he depicted as a “new strategy”—pounding the enemy, relaxing the rules of engagement, and integrating diplomatic, economic, and military power to achieve victory—when, in fact, this was nothing new and certain key terms, for instance victory, were left undefined. More than a year after his escalation, nothing in Afghanistan has changed, except that the Afghan Army is shredding and the deaths are on the rise. Bob Woodward’s book, Fear, quotes Trump telling aides that he should have stuck to his instincts—though he hasn’t since acted on his regrets either.

So, what to do? Most analysts, on all sides of the issue, agree that simply pulling out would spark disaster—anarchy, civil war, the return of a terrorist regime, the strengthening of ISIS—in a region of nuclear powers and great instability already.

A negotiated settlement is the only way out. The Taliban seem disinclined to negotiate at the moment, since they’re winning on the battlefield. But they might be lured to peace talks if the reward were sufficiently enticing, and the only reward that might bring them is the prospect of a U.S. withdrawal—though not an unconditional withdrawal.

Afghanistan is a nexus of international interests and intrigue. China, Russia, Iran, and Pakistan all have geopolitical and economic interests in its future. America’s relations with all four countries are dismal at the moment; yet, we depend on at least one of them at any given time for basing and overflight rights to supply our troops there—which means it isn’t entirely out of the question to work with at least two or three to contrive a peace.

China, which has investments in Afghan copper mines, has offered to help train troops to fight off jihadists, if just to protect its mercantilist interests. So has, to a lesser extent, Russia. Washington has resisted on both counts, not wanting to share the territory. This is shortsighted. China, Russia, Iran, and Pakistan all have their reasons to oppose a jihadist-controlled Afghanistan, and—whatever our other issues—we should form an international conference, perhaps mediated by a U.N. agency or some other neutral power, on Afghanistan’s final status. This would have to be done with Pashtun, Tajik, and other ethnic factions, as well as with elements of the Taliban—which, unlike al-Qaida and ISIS, is made up of local Afghans.

(If we were to look at Afghanistan with fresh eyes, as if the past 17 years hadn’t taken place, we might well view the Taliban—preferably a Taliban embedded in a multiethnic Afghan political order—as an ally of convenience in the fight against ISIS.)

Timetables would have to be set, with benchmarks and step-by-step measures of Western military withdrawal and internal political settlement. If we get closed out of mineral rights, if the process ends up strengthening the bonds among Russia, China, and Iran, well, so be it.

Afghanistan isn’t likely to settle into a land of harmony for many years. Let someone else take up the burden.