Mr. Trump’s visit to Al Asad in December provoked similar anger from Iraqi politicians, some of whom called it an arrogant affront that recalled American behavior dating back to the 2003 invasion and what followed: the abuses at Abu Ghraib prison; incidents with civilian casualties; and widespread sectarian violence.

The decision that upset the broadest spectrum of Iraqis was the departure of American troops from the country once the status of forces agreement, which set the terms for United States forces in Iraq, expired in 2011. Although American troops had little choice but to leave the country after the expiration — and though Iraq’s leaders played a large role in their exit — many Iraqis now describe the departure as an abandonment and part of what led to the growth of the Islamic State and continued fighting on Iraqi soil.

“It will not be forgotten what happened after the American withdrawal,” said Jowad al-Musawi, a member of Parliament from the bloc allied with Moktada al-Sadr, a Shiite leader. “It will not be forgotten that America would at any moment leave you alone to confront war or terrorism.”

With the Islamic State’s territory in Iraq and Syria dwindling to just a sliver, many Iraqis are not sure what American forces are doing and where they are now based. They are fearful that Iraq will become the turf for a conflict between the United States and Iran, and they recognize that many Iraqis rely on Iran, which in recent years has been an ally, supplying some of southern Iraq’s electricity and supporting Iraq when the Islamic State invaded in 2014.