He arrived at Bagram Air Base shortly after 8.30pm local time and spent more than two and a-half hours on the ground, at one point serving Thanksgiving food to military personnel.
The plans were kept under wraps for his own safety, and his public schedule had said he would be at Mar-a-Lago to host a videoconference call with troops. While in Afghanistan, Mr Trump said he hopes to bring the number of troops in Afghanistan down to 8,600 from the current 14,000.
Sharing the full story, not just the headlines
He also met with Afghan president Ashraf Ghani, and said during their meeting: “The Taliban wants to make a deal, and we’re meeting with them and we’re saying it has to be a ceasefire, and they didn’t want to do a ceasefire, and now they do want to do a ceasefire. I believe it’ll probably work out that way.”
The visit comes more than two months after Mr Trump broke off peace talks with the Taliban after a bombing in Kabul killed 12 people, including an American soldier.
He was joined on the trip by White House national security adviser Robert O’Brien, a small group of aides and secret service agents, as well as a pool of reporters.
Earlier this month, a helicopter crash in the country brought the number of US deaths in Afghanistan this year to 19. This year has already been the deadliest for the US military since the troop surge of 2014. More than 2,400 Americans have died in the nearly 18-year war.
The president and first lady made a similar trip last year to Iraq at Christmas – their first visit to an active conflict zone.
Vice president Mike Pence visited troops in Iraq this week.