The president returned to the White House Thursday morning, announcing it on Twitter.
The U.S. has more than 5,000 troops in Iraq that help to support the government in its fight against the Islamic State group, also known as ISIS, according to The Associated Press. The group has lost a significant amount of territory in Iraq, the AP reported, although it remains a threat.
The visit comes a week after Trump announced he would withdraw American military forces from Syria in a move that stunned Republicans and led to the resignation of Defense Secretary James Mattis.
Trump has also ordered a reduction of the 14,000 U.S. troops stationed in Afghanistan, CNN reported. On Wednesday, he told reporters in Iraq that he had no plans to pull American military forces out of Iraq.
"If we see something happening with ISIS that we don't like, we can hit them so fast and so hard they really won't know what the hell happened," Trump said, according to Bloomberg. "We've knocked them silly."
Trump, who has been criticized for failing to visit American troops in conflict zones since taking office in 2016, was in Iraq for about three hours, Reuters reported. On his way back to the U.S., the president was expected to make a stop in Germany to visit troops at Ramstein Air Base, according to Reuters.