BAGRAM AIRFIELD, Afghanistan — President Donald Trump made a surprise visit to Afghanistan on Thursday to visit American troops for Thanksgiving.

The trip, his first to the country, comes almost a year after the president made a surprise visit to troops stationed in Iraq, his first to a combat zone since he took office.

He served Thanksgiving dinner to troops at Bagram Airfield before discussing the stalled peace talks with the Taliban militant group.

Flanked by armored vehicles and an Apache attack helicopter, the president teased some new developments.

"We will see if the Taliban wants to make a deal. If they do, they do. If they don't, they don't. We were getting close," he told around 500 U.S. personnel in a dining hall at the base.

After nine rounds of negotiations the president announced in September that he was calling these peace talks off after a U.S. service member was killed in a suicide attack in the capital Kabul.

"They thought that was good negotiating power," he said, referring to the Taliban's reaction to the attack and his pullback. "That's bad negotiating power and since then we've hit them so hard."

Asked by the pool whether talks had restarted Trump said "yes" without giving details. Chairman of the Joint Chiefs of Staff, Gen. Mark Milley, added that "hopefully they will be successful and lead to Afghan-to-Afghan dialogue in the near future."

Milley said Wednesday he was optimistic the negotiations would resume.

Afghan presidential elections were held in September but the results have not yet been released. The country's incumbent president, Ashraf Ghani, tweeted about Trump's visit Thursday.

He said that he and his American counterpart discussed "important progress we have jointly made in our military efforts in the battlefield" and that Trump "appreciated the tireless efforts of the Afghan security forces in this fight."

Today, I met with President Donald Trump (@realdonaldtrump) at the Bagram Air Base. pic.twitter.com/VFHgG7hGaB — Ashraf Ghani (@ashrafghani) November 28, 2019

Around 13,000 U.S. personnel are still stationed in Afghanistan to train, advise and assist local forces under a NATO mission, and to conduct counterterrorism operations.

Trump said this summer that he aimed to reduce that figure, and last month the top U.S. general in Afghanistan said the total number of troops in the country had decreased by around 2,000.

"We're bringing down the number of troops substantially," Trump said during his visit Thursday.

The war in Afghanistan is the longest in U.S. history, claiming some 147,000 lives since the conflict started in 2001, including about 40,000 civilians, 60,000 Afghan security forces and 3,500 coalition troops — about 2,400 of them Americans, according to a study from Brown University.

The U.S.-led invasion toppled the Taliban government from power after it harbored 9/11 mastermind Osama bin Laden.

Department of Defense spending in Afghanistan has so far cost the U.S. taxpayer $765 billion, and the Afghan government still only controls some 53 percent of the country's territory amid the ongoing conflict, according to a report by a U.S. government watchdog.

The visit comes at a tumultuous time in the Trump presidency, following public testimony from senior diplomats in the House impeachment inquiry. They portrayed the president's attempts to pressure Ukraine to investigate former Vice President Joe Biden, a potential Democratic rival in the 2020 presidential race, an allegation Trump denies.

Mosheh Gains reported from Afghanistan. Alexander Smith reported from London.