The president tweeted video clips from his visit with the service members as Lee Greenwood's "God Bless the U.S.A." played.
“President Trump and the First Lady traveled to Iraq late on Christmas night to visit with our troops and Senior Military leadership to thank them for their service, their success, and their sacrifice and to wish them a Merry Christmas,” White House spokeswoman Sarah Sanders announced on Twitter Wednesday afternoon.
The president and first lady spent about three hours on the ground at al-Asad, which is the main U.S. military base in western Iraq’s Anbar Province -- the birthplace of the Islamic State. During his time at the base, the president met with troops and senior military commanders and made remarks to troops gathered on site.
"We're no longer the suckers, folks," Trump told the service members, according to the Associated Press. "We're respected again as a nation."
During the visit, Trump spoke by phone with Iraqi Prime Minister Adil Abdul-Mahdi after the leaders were scheduled to meet in person at the base but it was canceled for security and logistical reasons. During the call, Trump invited Abdul-Mahdi to visit the White House, which the prime minister accepted.
After departing Iraq, the president and first lady flew to Ramstein Air Base in southwestern Germany, where they arrived at 1:37 a.m. local time. Trump met with U.S. troops and military leaders stationed there Wednesday evening before departing for Washington, D.C., where he is expected to land early Thursday morning.
Trump’s visit comes after the president’s decision to withdraw American troops from Syria surprised Washington, blindsiding lawmakers, members of the administration and American allies across the world and on the ground fighting ISIS in Syria.
During his visit to al-Asad on Wednesday, the president said he has "no plans at all" to remove U.S. troops from the country, according to AP. Iraq hosts approximately 5,200 American troops, according to the Pentagon.
Spokesperson for the first lady, Stephanie Grisham, said President Trump and Melania were initially planning to leave from Florida for Iraq. This was not a random trip that was influenced by the shutdown and had been planned for six weeks, Grisham said.
"We would have left regardless of where we were," Grisham said from Iraq with the first lady. "This has been in the works for weeks. It was a priority for both of them."
While there was talk of going to Afghanistan, a former senior White House official said that Trump was concerned about the security in Afghanistan after he saw a "60 Minutes" report on the region.
"He ranted about how unstable it was on the ground. It left the impression on him that [the U.S.] had a complete loss of control," the former official said.
Trump also was concerned about the price of running helicopter taxis to avert the Taliban.
On Thursday, the Trump administration announced it was planning to reduce the number of U.S. troops in Afghanistan, cutting the current force of 14,000 service members to 7,000. Those troops could return home by the end of spring, an American official told ABC News.
Defense Secretary James Mattis also resigned Thursday, after the decision was made, having clashed with the president over policy and their divergent worldviews and philosophies on American military power.
While his resignation letter said he would stay on until the end of February to ensure a smooth transition, Trump moved up the timeline, forcing Mattis out of the administration by the end of the year.
Deputy defense secretary Patrick Shanahan, a former Boeing executive with no prior military or government experience, will replace the retired Marine in an acting capacity.
The president has faced criticism for neglecting to visit troops in a combat zone earlier in his presidency. But during his remarks to troops at Al Asad on Wednesday, Trump suggested that he would have visited earlier but for security concerns.
“We actually had a couple set up but were canceled for security reasons because people were finding out. Pretty sad when you spend 7 trillion dollars in the Middle East and going in has to be under this massive cover with planes all over and all of the greatest equipment in the world and you do everything to get in safely,” Trump said Wednesday.
Trump’s immediate predecessors each visited troops in the region much earlier: President George W. Bush first traveled to Baghdad in Nov. 2003, roughly eight months after ordering American troops to Iraq.
President Barack Obama, who first visited Iraq as a senator, made his first trip as commander-in-chief in April 2008, roughly three months after taking office.
Trump first visited with troops overseas in Italy in May 2017, roughly four months after taking office.
His visit Wednesday, the day after Christmas, continues a long tradition of presidents visiting with service members at home or abroad during the holiday season. On Christmas Day, Trump participated in a video call with service members serving across the country and overseas during the holidays.
ABC News' Luis Martinez and Amanda Maile contributed to this report.