The Wednesday visit, Trump's first with US troops in a conflict zone since he took office two years ago, came days after a shock decision to pull all American troops from neighbouring Syria.
No visit to PM?
Trump's trip was veiled in such secrecy there was speculation that Iraqi authorities had not been informed, and the US leader did not meet with Iraqi officials.
There were no face-to-face talks between Trump and Iraqi Prime Minister Adel Abdel Mahdi due to "differing views on how to organise the meeting", Iraqi authorities said in a statement.
The two leaders instead spoke over the phone, the statement added.
In Iraqi media, rumours abounded that Trump had asked Abdel Mahdi to meet him at the military base but the premier declined.
"What was supposed to pass for a face-saving story -- that Trump refused to meet the PM in Baghdad insisting that the meeting take place at the Ain Al-Asad base -- was viewed by many Iraqis as further proof of Trump's contempt for Iraq," said Fanar Haddad, an Iraq expert at the National University of Singapore's Middle East Institute.
"The excuse made the initial infraction all the worse," said Haddad.
Former prime minister Haider al-Abadi said the way in which Trump visited Iraq was "not commensurate with diplomatic norms and relations with sovereign states".
"Dealing with Iraq and its sovereignty in this way will harm Iraqi-US relations," he said.
Trump's visit follows his surprise decision to withdraw all 2,000 American troops in neighbouring Syria and half of the 14,000 US soldiers deployed in Afghanistan to fight the Taliban.
But Trump stressed during his visit that he had no intention of pulling troops out of Iraq, which he said could be used as a future base "if we wanted to do something in Syria".
"I think the visit will reassure those fearing that US policy in Iraq will go the way of its policy in Syria," said Haddad.
Trump has made disentangling the US from its wars a priority since his 2016 election.
The US "cannot continue to be the policeman of the world", he told troops at the Iraqi base.
But Iraq is a special case, according to Iraqi political analyst Hisham al-Hashemi.
"Iraq is important because of its strategic location. The presence of US forces reassures both Jordan and Saudi Arabia, and strikes a balance between the Kurds and Turkey and the Turkish, Iranian, Iraqi triangle," he said.
The US military presence in Iraq also aids "Israel's desire to block the Tehran-Beirut route" and helps offset Iran's strengthening presence in the region, he said.
Iraqi political scene?
Relations between Iraq and the US have seen sizeable shifts since the 2003 US invasion and the overthrow of longtime ruler Saddam Hussein.
The US military presence was largely unwelcome for years, until Washington created the international coalition to defeat IS in 2014 and helped erase the jihadists' "caliphate".
But Iran's growing influence in the country has worked to diminish pro-US sentiments and pro-Tehran groups now make up a key bloc in the Iraqi parliament.
Those groups were angered by Trump's visit.
The Iran-backed Harakat al-Nujaba said the presence of US forces in Iraq was a "violation of the country's sovereignty" and it was "now the duty of the government to expel American forces".
"Trump's disrespect of Iraq's sovereignty will not go unpunished," it said, adding it would "not allow Iraq to be a base used to threaten other countries".
The head of the pro-Iran Asaib Ahl al-Haq group, Qais al-Khazali, tweeted that "Trump's visit to a US military base without regard for diplomatic norms reveals the reality of the American project in Iraq".
The Iraqi response, he said, "would be the parliament's decision to remove your military forces" unilaterally.
"If you don't withdraw, we have the experience and the ability to remove them in another way," he added.
With Abdel Mahdi still struggling to fill key ministerial positions months after his appointment, analyst Hashemi said the "axis close to Iran will seek a parliamentary vote on a timeline for an American pullout from Iraq".
These groups and their respective militias play a major role in maintaining security across much of Iraq, especially along the border with Syria.
Hashemi said Trump's "disregard for his allies is straining the relationship between Abdel Mahdi and the Iraqi political forces".
Trump's ignorance of Iraq's tenuous political scene, he said, may "open the doors for resistance against the American presence in Iraq again".