The walls of the American Embassy in Baghdad were still on fire and members of pro-Iranian armed groups were chanting threats outside when Iraq’s prime minister tried to explain the situation to President Trump. “Iraq is between friends who are 5,000 miles away from us and a neighbor we’ve had for 5,000 years,” Prime Minister Adel Abdul Mahdi said in a New Year’s Day telephone call with Mr. Trump, according to a close adviser, Abdul Hussain al-Hunain. “We cannot change geography and we cannot change history, and this is the reality in Iraq. ”

Iraq is caught in a vise.  Many Iraqis were furious that the United States violated their country’s sovereignty by carrying out airstrikes on Iraqi soil. A spate of strikes in December killed at least two dozen members of a pro-Iranian Iraqi military unit, provoking the assault on the American Embassy.

A separate strike last week killed Iran’s top military commander, the deputy chief of a coalition of Iraqi militias and eight other people, leading to a vote by Iraq’s Parliament to expel American forces from the country and a counterstrike by Iran on two American military posts in Iraq early Wednesday.But acceding to the political pressure to rid the country of American troops would be a “disaster” for Iraq, militarily and economically, a senior Iraqi official said.