BAGRAM AIR FIELD, Afghanistan — President Trump paid an unannounced Thanksgiving visit to American troops here on Thursday and said that he had restarted peace negotiations with the Taliban less than three months after he scuttled talks with the group.
“The Taliban wants to make a deal, and we’re meeting with them,” Mr. Trump said here during a meeting with Afghanistan’s president, Ashraf Ghani.
“We’re going to stay until such time as we have a deal, or we have total victory, and they want to make a deal very badly,” said Mr. Trump, who reaffirmed his desire to reduce America’s troop presence here to 8,600, down from about 12,000 to 13,000.
Mr. Trump made his first visit to Afghanistan under a shroud of secrecy, arriving in a darkened airplane just after 8:30 p.m. local time and departing a few hours later on a trip that the White House had concealed from his public schedule for security reasons.
Mr. Trump carried out the traditional role of feeding turkey and mashed potatoes to American troops in fatigues, before dining, mingling and posing for photographs before he delivered remarks celebrating America’s military in an aircraft hangar.
But his visit also had an important political dimension, and comes at a crossroads for Afghanistan and the United States military presence here after Mr. Trump angrily called off his talks with the Taliban in September, which had come close to reaching an agreement that would begin the phased withdrawal of American forces from the country.
Mr. Trump, who boasted of American military successes against Al Qaeda and the Islamic State, suggested that the Taliban is eager to make a peace deal, but that he himself is indifferent to that outcome.
“The Taliban wants to make a deal — we’ll see if they make a deal. If they do, they do, and if they don’t they don’t. That’s fine,” Mr. Trump said.
He also said that the Taliban is now willing to agree to a cease-fire, a matter of contention in the earlier talks and something that Mr. Ghani’s government has been insistent upon.
“We’re saying it has to be a cease-fire, and they didn’t want to do a cease-fire,” Mr. Trump said of the Afghan insurgents. “Now they do want to do a cease-fire. I believe it’ll probably work out that way.”
Mr. Trump’s suggestion that the United States would either reach a peace with the Taliban or achieve “total victory” is a sharp departure from his public frustrations with what he has called America’s unending wars. American military leaders and diplomats have long ruled out the possibility of a military victory in Afghanistan. To the contrary, they say, a political settlement is the only way out of the war.
American diplomats have quietly tried to keep the peace process alive since the president called off the talks, using small measures like a prisoner swap to build trust. In recent weeks, informal meetings between the two sides have been reported, though neither side has publicly acknowledged that peace negotiations have formally resumed.
Even after Mr. Trump broke off negotiations, the Taliban refrained from criticizing him too harshly, which analysts took as evidence that the group still wanted a deal with the United States.
But while the Afghan government has long demanded that the Taliban agree to a cease-fire, no evidence has emerged that the group was willing to grant one. Instead, it has said it would discuss the possibility in negotiations with Afghanistan’s political leaders over the future of the country once the Americans had agreed to leave.
The trip also allowed the president to stand against a backdrop of visible military support amid his decision to intervene in several high-profile war crimes cases, which has roiled the Pentagon and strained his relations with military leaders.
The secretary of the Navy, Richard V. Spencer, was fired after Mr. Trump refused to allow the Navy to oust Chief Petty Officer Edward Gallagher from the Navy SEALs after he was convicted on a charge related to accusations of misconduct but acquitted of the most serious allegations, including shooting civilians, killing a captive Islamic State fighter with a hunting knife in Iraq and threatening to kill SEALs who reported him.
“This was a shocking and unprecedented intervention in a low-level review,” Mr. Spencer wrote in The Washington Post on Wednesday.
Mr. Trump arrived in Afghanistan one day after at least 13 people were killed when their car struck a roadside bomb on the way to a wedding party in Taliban-controlled territory northern Afghanistan, officials said. Most of the victims were related to each other.
Administration officials say Mr. Trump remains eager to bring an end to the American role in Afghanistan, which costs billions of dollars each year and continues to claim American lives. Earlier this month, Mr. Trump visited Dover Air Force Base in Maryland to pay his respects during the return of two Americans killed in a Nov. 20 helicopter crash in Afghanistan.
Mr. Trump is also searching for foreign policy achievements he can celebrate on the campaign trail over the next year. Several of his other marquee initiatives, including nuclear talks with North Korea and an effort to squeeze concessions out of Iran with economic pressure, have yielded few results.
The peace negotiations with the Taliban collapsed in stunning fashion on Sept. 7, after Mr. Trump disclosed via Twitter that he was quashing plans for a dramatic meeting at his Camp David presidential retreat with Taliban leaders and Afghan government officials. Angrily citing a Taliban attack in Kabul which killed an American soldier as the plans were coming together, Mr. Trump called off the discussions entirely.
It was never clear how imminent a peace agreement truly was. Taliban leaders said they had not committed to a Camp David visit, and Afghanistan’s president, Ashraf Ghani, was deeply skeptical of a United States agreement with the Taliban.
And uncertainty about the country’s future in the wake of its disputed election results could make brokering a meaningful peace difficult.
Mr. Trump may be proceeding on his own. The goal of his past talks with the Taliban was to trade an American pledge to withdrawal for a Taliban renunciation of its terrorist allies like Al Qaeda and the start of Taliban negotiations with Afghanistan’s government.
But American troops are already exiting the country. A month ago, the top American commander in Afghanistan, Gen. Austin Miller, said that United States forces in the country had dropped by 2,000 over the last year.
Some current and former military officials are worried that Mr. Trump’s appetite for a troop reduction he can boast about on the campaign trail as a fulfillment of his promise to scale back American foreign interventions could lead to serious national security risks.
Retired Gen. David Petraeus, a former commander of American forces in Afghanistan, has warned that a premature withdrawal could lead to a Taliban conquest of the country, and Senator Lindsey Graham, Republican of South Carolina and a close adviser to Mr. Trump on foreign policy, has said removing troops could “pave the way for another 9/11.”
Mr. Trump flew to Afghanistan on one of the modified blue-and-white 747 jets known as Air Force One when the president is onboard. Mr. Trump had flown to Florida on Tuesday in another one of those planes but left it behind for his secret trip to Washington, where he boarded an alternate plane out of public view.
Also joining Mr. Trump for the trip were his acting chief of staff, Mick Mulvaney; the national security adviser, Robert C. O’Brien; the White House press secretary, Stephanie Grisham; his social media director and adviser Dan Scavino; and Senator John Barrasso, Republican of Wyoming and a member of the Senate Foreign Relations Committee who has paid regular holiday visits to troops here.
White House officials did not officially tell reporters on the trip their destination until well into the 13-hour flight and had their phones and other signal-emitting devices confiscated before boarding.
Ms. Grisham acknowledged that the White House had arranged for Mr. Trump’s Twitter account to post messages while he was in the air, to prevent an unusually long silence that might draw suspicion about his activities.
Mujib Mashal contributed reporting from Kabul, Afghanistan.