U.S. troops patrol at an Afghan National Army base in Logar province, Afghanistan, on Aug. 7, 2018. (Omar Sobhani/Reuters)

A TENTATIVE deal between the Trump administration and the Taliban appears to offer the United States a negotiated way out of its longest war — a prospect most Americans would welcome. Unfortunately, it seems to do so mostly on the enemy’s terms. U.S. forces would leave the country, but there would be no guarantee that the government and political order they have spent 17 years defending, at enormous cost, would survive — or that the gains Afghans have made in women’s and other civil rights would be preserved.

As described by envoy Zalmay Khalilzad, the “framework” for an accord reached in talks last week begins with a commitment by the United States to a troop pullout and a Taliban pledge to prevent Afghan territory from serving as a base for international terrorism. Mr. Khalilzad said that bare-bones exchange could be supplemented by the Taliban’s agreement to a cease-fire and talks with the Afghan government. But the insurgents have not yet agreed to those steps; the group is to conduct internal consultations about them before talks resume next month.

Unless it were linked to a full peace settlement, a withdrawal of U.S. and NATO forces would leave the Afghan government deeply vulnerable. As it is, its army and police forces have been suffering heavy losses and losing ground to the Taliban even with the backing of a modest number of Western troops. While some analysts believe the Taliban would not seek to re-create the fundamentalist and profoundly repressive regime they led up until late 2001, they remain implacably hostile to democracy. Afghan women say they fear any end to the conflict would come at their expense.

It’s also not clear how the Taliban would deliver on its promise to “prevent Afghanistan from ever becoming a platform for international terrorist groups or individuals,” as Mr. Khalilzad described it to the New York Times. As it is, a branch of the Islamic State has entrenched itself in the mountainous east of the country, with the aim of establishing a new caliphate. U.S. and Afghan government forces have been unable to eliminate the terrorists, and it’s hard to believe the Taliban would have the capacity to do so even if it had the will.

Negotiations with the Taliban are the only way out of the Afghan war. When Mr. Trump increased U.S. troop levels to 14,000 in 2017, his purpose was to force the enemy to bargain. Now that bargaining is underway, the president has seemingly grown eager to pull the plug on the mission. Last month, he ordered the force reduced by nearly half. That, no doubt, has curtailed Mr. Khalilzad’s leverage. The Taliban may calculate that, rather than insist on an acceptable political settlement, the White House will settle for the fig leaf of their assurances about preventing terrorist attacks.

It should not. An end to the Afghan war is desirable, but not at the expense of everything the United States has helped to build there since 2001, including a civil society where girls go to school. President Ashraf Ghani warned Monday against rushing into a deal that could return Afghanistan to the chaos it saw following the Soviet withdrawal. He should be heeded.