WASHINGTON — President Trump met with top national security officials on Friday to review near-final plans for withdrawing American troops from Afghanistan, a prospect that has already prompted fierce political debate but could offer Mr. Trump a compelling talking point for his 2020 re-election campaign.

The president and his advisers gathered at his golf club in New Jersey to assess a deal reached with Afghan insurgents by his special envoy for Afghanistan, Zalmay Khalilzad, during several months of negotiations in Qatar. Mr. Trump is a longtime skeptic of the United States’ 18-year military presence in Afghanistan and campaigned against expensive foreign interventions.

His decision point on Afghanistan, and the widespread belief that he is impatient to begin a withdrawal before the next election, has already kicked off an argument in Washington about whether an exit would amount to a premature retreat or a crucial step toward long-overdue peace. That debate scrambles partisan lines, with some prominent Republicans warning that leaving would be reckless, while top Democrats applaud the idea of concluding the war in Afghanistan, a goal that eluded President Barack Obama.

For Mr. Trump, initiating a departure from Afghanistan would allow a president who once promised to “bomb the hell out of” terrorists and has spoken of wiping Afghanistan “off the face of the earth” to present himself as a peacemaker.

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.

Skeptics say it is naïve to trust Taliban assurances. Mr. Joscelyn insisted that a potentially fatal flaw would be a failure to ensure that the Taliban, which he said have perfected “weasel” language, specifically name groups that they will shun. Another person familiar with the draft agreement said that had been a sticking point in the negotiations. But defenders of the deal say any withdrawal would be conditioned on the Taliban delivering on their promises.

Among those meeting with Mr. Trump on Friday in Bedminster, N.J., where he is spending a working vacation, were Vice President Mike Pence; Secretary of State Mike Pompeo; Secretary of Defense Mark T. Esper; John R. Bolton, the national security adviser; and Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff.

Mr. Khalilzad presented the group his agreement with the Taliban, which would be only a first step toward peace in Afghanistan. The Taliban have demanded that the United States commit to leaving Afghanistan before their leaders begin negotiations with the country’s United States-backed government over its political future. Details of that process remain unresolved and could threaten the pace of American withdrawal.

Even if the Taliban reach an agreement with the Afghan government, current and former government officials fear it may be only a matter of time before they seek to reconquer the entire country, as they did in the 1990s, creating a radical religious government that provided safe haven to the Al Qaeda leader Osama bin Laden.

He had inherited a troop presence of 8,400 from Mr. Obama, who after approving a peak force of 100,000 in 2011 significantly lowered his expectations for defeating the Taliban and reshaping the shattered Central Asian country.

The Taliban are Sunni Muslim fundamentalists who for years have battled Afghan and American forces, and have mounted ruthless terrorist attacks on civilians. But even as they provided Al Qaeda with continued harbor, the Taliban did not seek to conduct terrorist attacks beyond Afghanistan, and they have battled openly with the Islamic State, whose presence has grown in the country in recent years.

Supporters of an extended troop presence in Afghanistan are trying to remind Mr. Trump of Mr. Obama’s withdrawal from Iraq in 2011. Iraq’s security forces were unprepared to fight on their own and, three years later, the Islamic State rampaged through the country, capturing major cities and plotting attacks against the West.

In a Wall Street Journal op-ed article last week, David H. Petraeus, a retired Army general who commanded United States forces in Afghanistan under Mr. Obama, warned that a “complete military exit from Afghanistan today would be even more ill-advised and risky than the Obama administration’s disengagement from Iraq.”

“President Trump should learn from President Obama’s mistakes,” Senator Lindsey Graham, Republican of South Carolina, who often advises the president, said Friday in a statement. “Any peace agreement which denies the U.S. a robust counterterrorism capability in Afghanistan is not a peace deal.”

Democrats are sympathetic to the goal of wrapping up the war. In a Democratic presidential primary debate in June, Mayor Pete Buttigieg of South Bend, Ind., who served in Afghanistan, reflected on his party’s prevailing opinion when he declared: “We will withdraw. We have to.”

And a former senior Obama administration official who worked on Afghanistan policy offered positive reviews for the emerging plan as he understood it.

“It’s a very complex problem,” the former official said. “I’d have a hard time improving upon what they’ve come up with, and give them credit for making progress with something that has been years in the making.”

In a statement on Friday evening, Mr. Pompeo said that the United States was working closely with the Afghan government toward a “comprehensive peace agreement, including a reduction in violence and a cease-fire, ensuring that Afghan soil is never again used to threaten the United States or her allies, and bringing Afghans together to works towards peace.”

It is unclear when or where Mr. Trump might announce that he has reached an agreement with the Taliban, and Mr. Khalilzad may return to Qatar for still more talks before that happens. Mr. Joscelyn said on Friday that several government officials have told him they expect Mr. Trump’s initial decision to be delivered via Twitter.

The United States invaded Afghanistan weeks after the Sept. 11, 2001, terrorist attacks, which were planned and directed from the country by Bin Laden. In the nearly 18 years since, the war has killed tens of thousands of Afghans and more than 3,500 American and coalition forces, and its price tag is in the hundreds of billions of dollars.

Speaking to reporters alongside Pakistan’s prime minister last month, Mr. Trump sent clear signals of his desire to end America’s role in the conflict, complaining that the war’s duration was “ridiculous” and that the United States was “not fighting to win” but “building gas stations” and “rebuilding schools.”

“The United States, we shouldn’t be doing that,” the president said. “That’s for them to do.”

A version of this article appears in print on , Section A, Page 10 of the New York edition with the headline: Debate Flares Over Afghanistan as Trump Considers Troop Withdrawal. Order Reprints | Today’s Paper | Subscribe