On Sunday, just days after the U.S. strike that killed the powerful Iranian military commander Qassem Soleimani, the Trump administration got its first real taste of international pushback. The Iraqi parliament voted to oust American troops from the country and Tehran announced that it would pull completely out of its obligations under the 2015 nuclear deal.

The pushback didn’t come in the form of a targeted strike on a major American outpost or U.S. service member, but combined, the two events served as a wakeup call for officials in Washington who for days had tried desperately to manage the fallout of the Soleimani strike, with some describing it as an act to “advance the cause of peace.”

President Donald Trump’s truculent response? Threaten Iraq with sanctions if it expels U.S. troops: “If they do ask us to leave, if we don’t do it in a very friendly basis, we will charge them sanctions like they’ve never seen before ever. It’ll make Iranian sanctions look somewhat tame.”

Tehran’s announcement about its nuclear program Sunday indicated that the efforts Iran and the United States made in recent months to discuss the possibility of negotiations had all but evaporated. And the Iraqi vote in parliament, although nonbinding, worried officials in the State Department who for days had tried to convince officials in Iraq that backing America’s presence in the country was still the best bet for a continued partnership.

In response to Sunday’s events Trump threatened “disproportionate” strikes against Tehran and indicated he would not be constrained by anyone on the Hill.

“These Media Posts will serve as notification to the United States Congress that should Iran strike any U.S. person or target, the United States will quickly & fully strike back, & perhaps in a disproportionate manner. Such legal notice is not required, but is given nevertheless!” the president raged on Twitter on Sunday afternoon.

Sunday’s maelstrom and new developments were not entirely unexpected by Trump’s national security brass or his war planners. Shortly before he ordered Thursday’s fateful, potentially world-altering attack, the president was briefed on a menu of possible consequences if Soleimani were slain. According to two administration officials, one of the listed potential consequences was attacks on U.S. military personnel abroad—and another was the Iranian regime deciding to amp up its nuclear program.

For senior Iraqi officials who have worked closely with the United States, including Prime Minister Adil Abdul-Mahdi, fears that their country will become the proxy battleground for a war between the U.S. and Iran have combined with a sense of betrayal by their American allies.

Last week, as Abdul-Mahdi worked to calm an increasingly explosive confrontation, he turned to Soleimani for help. An American contractor had been killed by a militia, Kataeb Hezbollah, that is part of the Iraqi government’s forces but which answered to Soleimani. Then came retaliatory U.S. airstrikes against Kataeb Hezbollah, killing at least 24 people. The militia’s supporters responded by trying to batter their way into the fortress-like U.S. Embassy compound in Baghdad’s Green Zone.

The Iraqis had known that Soleimani could make the violence worse—or he could rein in the many Iraqi militias over which he held de facto command, and thus ease the tensions.

When the embassy siege ended, Abdul-Mahdi got a phone call from Trump thanking his government, and Trump asked him “to play the mediator’s role” between the U.S. and Iran. But Trump already had ordered the drones and helicopters set in motion to terminate the Iranian general in a fiery blast early last Friday morning near Baghdad airport.

Trump claims he ordered the hit to stop a major attack on Americans. But Abdul-Mahdi told Iraq’s parliament Sunday, “I was supposed to meet Soleimani the day he was killed.” He had come to deliver “a message from Iran responding to the message we delivered from Saudi [Arabia] to Iran.”

“ Abdul-Mahdi offered parliament only two options: that the U.S. pull out deliberately and slowly or that it do so as quickly as possible. ”

Abdul-Mahdi and other Iraqi officials, framing this as duplicity from Trump, apparently feel they have little choice at this point but to demand American forces withdraw. Indeed, as the vote approached on the nonbinding resolution Sunday, Abdul-Mahdi offered parliament only two options: that the U.S. pull out deliberately and slowly or that it do so as quickly as possible. And Abdul-Mahdi, long considered friendly by Washington, said he favored the second option.

In the hours after Soleimani’s fiery demise, senior officials in the State Department were tasked with reaching out to officials throughout Iraq to try to ease fears that the country would yet again become an American battlefield. But the more pressing concern for the State Department and the White House, according to two senior U.S. officials, was convincing politicians in Baghdad and Erbil, the capital of Iraq’s Kurdistan Regional Government, that they should continue to support the presence of U.S. troops in the country. Axios was the first to report that the U.S. reached out to Iraqi officials to try and stop the vote in parliament.

For more than a year, leading Iraqi politicians have called on the U.S. to withdraw, saying their presence was only inflaming tensions on the ground with Iran-backed militias. And the most important push by the State Department was to shore up Kurdish support—to ask that Kurd members of parliament not show up for a vote that would oust American troops from the country.

The outcome wasn’t 100 percent predictable, sources said. For months American diplomats in Iraq have privately raised concerns that the Kurds were unhappy with the U.S., that they felt they could not rely on a Trump White House.

The Kurds, and many Sunni members of parliament, did not show up for the vote, which can be construed as a de facto show of support for the U.S. position. But parliament still voted for the removal of American troops from the country.

The vote cannot be implemented by Abdul-Mahdi’s caretaker government, so technically the U.S. forces have some breathing room. But the writing, as they said in ancient Babylon, is on the wall.

Senior officials at the Pentagon and State Department have discussed the possibility of moving American troops to the Kurdish region of Iraq. But with Kurdish support somewhat shaky, that option isn’t clear, either.

On Sunday night, Trump told reporters aboard Air Force One he would sanction Iraq “like they’ve never seen before” and that they would “make Iranian sanctions look somewhat tame.” "We're not leaving unless they pay us back,” Trump said, apparently referring to a U.S. air base in the country.

To much of the Iraqi government, Soleimani’s killing was a final straw. To the Iranian leaders and scores of the Islamic republic’s citizens, it was an act of war and a rallying cry to vengeance. To Trump’s stateside critics, it was yet another disastrous decision made by a spectacularly unfit commander in chief.

“ How do you avoid further escalation with the understanding that the Iranians have to do something? ” — Iraqi official friendly to the U.S.

But to Trump’s base and power centers of his party—MAGA faithful, conservative war hawks, religious right leaders—it was a cause for elation.

Robert Jeffress, a Dallas megachurch pastor and an outside adviser to Trump, said that as he watched the news early on Friday, the morning after the strike, he quickly rewrote the address he was set to deliver at an “Evangelicals for Trump” event to thank God “for a president like Donald Trump who is willing to confront evil and take action.”

And on Friday, President Trump went before the news cameras, shortly before his trip to that “Evangelicals for Trump” gathering in Florida, to insist to the world, “We took action last night to stop a war. We did not take action to start a war.”

Senior Iraqi officials are only too aware that American political considerations that could determine the fate of their nation are based largely on Trump’s re-election strategy at this point. The result, they suggest, is counterproductive.

“You are strengthening the guys”—the Iranians—“you want to weaken,” said one Iraqi official friendly to the United States. “But the question is what to do now.” Then he added ominously, “How do you avoid further escalation with the understanding that the Iranians have to do something ?”