They travelled there "late on Christmas night" to thank troops for "their service, their success and their sacrifice", the White House said.
Mr Trump said the US had no plans to pull out of Iraq, Reuters reports.
The trip came days after Defence Secretary Jim Mattis quit over divisions about strategy in the region.
The US still has some 5,000 troops in Iraq to support the government in its fight against what remains of the Islamic State (IS) group.
However, a planned meeting between Mr Trump and Iraqi Prime Minister Adel Abdul Mahdi was cancelled. Mr Mahdi's office said it was because of disagreements on how to conduct the meeting. A phone call between the two leaders was held instead, officials added.
What happened during Trump's visit?
Mr Trump, his wife and National Security Adviser John Bolton travelled on Air Force One to al-Asad airbase, west of the capital Baghdad, to meet military personnel in the base's restaurant.
He spent about three hours at the base in what is his first visit to the region.
Read More (...)