For a president who at times seems to be at war with his military leaders, it was a celebration of America’s troops that a small circle of aides planned carefully for weeks to prevent leaks that could scuttle the dangerous trip.

“It’s a long flight,” Trump joked after serving turkey in a cafeteria in Afghanistan on Thanksgiving night. “But we love it.”

Trump’s surprise 3½-hour stop marked his second visit to a combat zone and his first trip to Afghanistan, dropping into a region that cultivated the leaders of the Sept. 11 terrorist attacks.

Last year, after facing criticism for being in office nearly two years without visiting troops overseas, Trump had hinted for weeks that he would take a trip soon — “I’m going to a war zone,” he bristled when asked whether he was afraid to visit. No one was particularly surprised when an amateur British aircraft watcher tracked a Boeing VC-25A, one of the modified Boeing 747s serve as Air Force One, flying over Europe.

President Donald Trump (right) speaks during a meeting with Afghanistan President Ashraf Ghani on Thursday. | Alex Brandon/AP Photo

This year, Trump said nothing publicly before leaving his family, including first lady Melania Trump, at Mar-a-Lago for his secret visit to Afghanistan.

Cellphones, hot spots and any other devices emitting a signal were confiscated from everyone on Air Force One — yes, even from the president himself. But his staff ensured tweets would be sent from Trump’s Twitter account so Trump-watchers wouldn’t get suspicious because the Twitter-obsessed president wasn’t tweeting — as they did last year.

And this time, 12 of the 13 journalists who traveled with Trump — representing news wires, print and broadcast outlets — were picked up on the roof of a public parking garage near Joint Base Andrews, just outside Washington, and were not even told where they were traveling until just before they arrived in Afghanistan.

Trump secretly slipped out of Mar-a-Lago earlier that evening and departed from an undisclosed airport on a flight a little after 7. The 13th journalist on the Afghanistan trip — a television correspondent — was aboard that flight and described it in a pool report as “bare-bones, except for four blue leather chairs and a moderately fancy port-a-potty that had been brought in for the occasion.”

Trump greeted the crew of that plane and even stayed in the cockpit for takeoff, the pool report said.

The presidential aircraft that Trump had flown to Florida a day earlier remained parked at Palm Beach International Airport, allowing travelers to see the modified blue-and-white 747 aircraft known around the globe as Air Force One.

That was a decoy. Secretly, a twin plane also used as Air Force One was hidden inside a cavernous hangar at Joint Base Andrews — instead of being lit up on the tarmac as usual — allowing the president to clandestinely hop on a flight without the public catching on. He departed just after 10 p.m. for the nonstop flight to Bagram Airfield, the largest U.S. base in Afghanistan.

Reporters traveling with the president learned their destination from White House press secretary Stephanie Grisham two hours before their arrival. A digital clock in Air Force One's press cabin usually shows times in Washington, the plane's location and its destination. The time for the destination was left blank until landing in Afghanistan.

“It’s a dangerous area and he wants to support the troops,” Grisham said of the president. “He and Mrs. Trump recognize that there’s a lot of people far away from their families during the holidays, and we thought it’d be a nice surprise.”

Asked how the president was feeling, Grisham responded: “He’s good. He’s excited.”

Air Force One landed in the dark at 8:33 p.m. local time Thursday with the shades drawn and interior lights off for security reasons — just as it had taken off from the Washington area.

Two surveillance blimps could be seen overhead. It was quiet and dark except for a smattering of lights. The base smelled of burning wood and trash.

The president moved through the sprawling base in a 15-vehicle motorcade that included tan Toyotas with soldiers standing in the truck beds holding combat rifles. Trump was followed into each location by teams of heavily armed combat troops in fatigues, helmets and night-vision goggles.

Journalists were barred from reporting on the trip until just before their departure from Afghanistan, after briefly getting internet access on the base to file. For three hours, they watched the president — in a blue suit and a red striped tie — dish out turkey in a cafeteria, where troops were watching the Macy’s Thanksgiving Day Parade on television; pose for photos; and deliver remarks in a hangar to 1,500 military personnel.

For once, Trump made no mention of the troubles he’s facing at home. He didn’t discuss House Democrats pushing to impeach him in the coming weeks for pressuring Ukraine to open politically advantageous investigations against a potential 2020 opponent. He also didn’t mention his rift with military leaders, including a new one just days before this trip.

President Donald Trump speaks at a dining facility during a surprise Thanksgiving Day visit to the troops at Bagram Air Field, Afghanistan. | Alex Brandon/AP Photo

He entered to the song that greets Trump at every rally — “God Bless the USA” — and was greeted with loud cheers and chants of, “USA! USA!” About 50 troops in fatigues stood behind him on a makeshift stage with a helicopter parked stage left.

Trump heaped praise on the troops and bragged about his accomplishments, specifically praising the work to destroy the Islamic State and al-Qaida.

And he had a supporting actor on hand to praise him as well — Afghanistan President Ashraf Ghani, who met with Trump on the base earlier as the U.S. president announced the resumption of peace negotiations with the Taliban.

Ghani, before a sea of troops, complimented his counterpart for taking out leadership of the region’s major terrorist groups. “President Trump, people talked a lot about [Osama] bin Laden — but what you did to eliminate [Abu Bakr] al-Baghdadi, who was an organizer and not a talker — is a much greater accomplishment,” he said.

“Please thank your families for agreeing to miss you at this special occasion and for being here defending United States security and our freedom,” said the Afghan president, who learned of Trump’s trip just hours before his arrival. “Together, we will succeed. We will never forget what 9/11 brought us and we will never permit the repetition of 9/11 again.”

Trump told the troops stationed at Bagram that the war in Afghanistan "will not be decided on the battlefield” but by the people of the region with a political solution.

“And we will continue to work tirelessly for the day when we can bring each and every one of you home and safe to your family. And that day is coming … very soon," Trump said.

After a 13-hour journey, and a brief period on the ground, Trump also wistfully told the troops that his Thanksgiving meal had been cut short. “I sat down, I had a gorgeous piece of turkey and I was all set to go. … I had a bite of mashed potatoes and I never got to the turkey because Gen. [Mark] Milley said come on over, sir, let’s take some pictures. I never got to my turkey. It’s the first time at Thanksgiving that I’ve never had anything called turkey.“

Around midnight on Thanksgiving, Trump boarded Air Force One to head back to Florida. He landed briefly at an Air Force base in Germany, where the plane often refuels. But this time, instead of spending two hours refueling, the identical Air Force One — the decoy that had been parked at Palm Beach International Airport — was flown in to take Trump immediately home.

The president was back at Mar-a-Lago by 7:30 a.m. Friday, and within hours he headed out for a round of golf.