That could be particularly useful at a moment when his nuclear diplomacy with North Korea has achieved little tangible promise and his “maximum pressure” campaign against Iran has failed in its goal of bringing Tehran to the negotiating table, said Vali Nasr, a professor of international relations at the Johns Hopkins University School of Advanced International Studies.

“This is as close as Afghanistan has been to a political settlement to end this war,” Mr. Nasr said. “I do think if a deal is signed, Mr. Trump says that we can talk to our enemies and we can cut a deal with them. And to actually get a deal with the Taliban may domestically compensate for the lack of a deal with North Korea or Iran.”

But skeptics of the agreement — which has not been finalized and could still fall apart or be rejected by Mr. Trump — fear it is meant more for the American political calendar than for the complex realities of the Afghan conflict and the enduring terrorist threat against the United States, and warn that it could end in disaster for both countries.

“The withdrawal is coming. It’s not a matter of if, it’s a matter of when or how fast,” said Thomas Joscelyn, a senior fellow at the Foundation for Defense of Democracies. “My sense of it, though I can’t prove it, is that it’s all over with by Election Day 2020.”

Several people familiar with the agreement say that it provides for the phased withdrawal of thousands of American troops from Afghanistan, likely in a first step of 5,000, over a period of about two years or less. In exchange, the Taliban would renounce ties to international terrorism and promise not to harbor or assist groups like Al Qaeda or the Islamic State. That would address what has long been the United States’ stated mission in the country: to prevent Afghanistan from becoming a home base for terrorists who want to strike the West.