President Trump surprised troops and news outlets on Thanksgiving morning when he appeared in Afghanistan to thank troops for their service to the country and help serve a turkey dinner -- but doing so required extreme security measures to ensure both safety and to prevent the word from getting out.

"There's nowhere I'd rather spend Thanksgiving than with the toughest, fiercest warriors," Trump told troops on the ground. "I'm here to say Happy Thanksgiving and thank you very much. As president of the United States, I have no higher honor than serving as commander in chief."

TRUMP SAYS PEACE TALKS WITH TALIBAN HAVE RESUMED DURING SURPRISE VISIT TO AFGHANISTAN

But in order to make the visit, intense security and a host of other measures were required to ensure the news didn’t leak. The journey began Wednesday, where Trump snuck out of Mar-a-Lago.

Many of the details of how he did so are a secret, but the president flew out of an undisclosed airport in Florida on a small, also undisclosed, plane Wednesday evening.

On that flight bound for Joint Base Andrews, in Maryland, there was only one Fox News journalist, who was serving as the pool reporter. The plane was bare-bones, except for four blue leather chairs and a port-a-potty that had been brought for the occasion.

As part of the security measures phones were taken from all onboard, including senior White House officials. Trump greeted the crew but remained in the cockpit for takeoff.

When the plane landed in Joint Base Andrews later Wednesday evening, Trump switched to Air Force One — which was not lit up on the tarmac, but was instead hidden in a hangar. It took off from JBA with all interior lights off and the windows drawn.

The plane landed in Afghanistan on a pitch-black runway, while the pool was only allowed to take pictures of Trump’s arrival from a nearby van. Accompanying Trump was White House Press Secretary Stephanie Grisham, Acting Chief of Staff Mick Mulvaney, National Security Adviser Robert O’Brien, Deputy Press Secretary Judd Deere, and Sen. John Barrasso, R-Wyo.

Grisham said that only a tight circle of White House officials knew about the trip, and the White House even scheduled tweets to be sent out from the president’s account during the Internet blackout that he faced.

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

It certainly was a surprise to the troops, the public and the media -- catching some outlets completely flat-footed. Newsweek had to overhaul an article that it had earlier posted that reported the president would spend the day tweeting and playing golf.

TRUMP SAYS TALKS WITH TALIBAN ARE ‘DEAD,’ AFTER CANCELING SECRET CAMP DAVID SUMMIT

After serving and eventually sitting down for a Thanksgiving dinner -- that included turkey, mashed potatoes, cornbread, baked ham, mac and cheese, cornish hen and candied yams -- Trump took as many pictures as time would allow with troops.

He then met with Afghan President Ashraf Ghani. Due to security concerns, the White House notified Ghani only “a few hours ago,” according to the White House.

CLICK HERE TO GET THE FOX NEWS APP

Trump then finished his trip by addressing a few hundred cheering troops in the hangar on the airfield, bringing Ghani on the stage to also express his appreciation to the American troops. Trump told them that everyone was working hard to bring them back home.

“We will continue to work tirelessly for the day when all of you can go home to your families … and that day is coming very soon,” he said.

Fox News’ Brooke Singman, Andrew O’Reilly and Jenny Buchholz contributed to this report.