In the early hours of January 3, a US air raid killed General Qassem Soleimani, the head of the Iranian Islamic Revolutionary Guard Corps' (IRGC) Quds Force, as well as Abu Mahdi al-Muhandis, a commander of the Iraqi Popular Mobilisation Units (PMUs).

The attack may prove to be US President Donald Trump's most reckless foreign policy decision in the Middle East. It was a grave violation of Iraq's national sovereignty and it is likely to result in further instability in the country and beyond.

It came on the tail of mass protests in both Iran and Iraq which challenged the Islamic Republic both domestically and regionally. Trump's decision to approve the assassination of Soleimani, however, has given a lifeline to the Iranian leadership and its allies in Iraq by driving nationalist sentiments and turning attention away from the failings of the governments in Baghdad and Tehran.

Escalation in Iraq

After Trump's withdrawal from the 2015 Joint Comprehensive Plan of Action, or the "Iran deal", it was clear that the Islamic Republic would retaliate through its Iraqi proxies, undermining US influence in the Middle East.

As the US reimposed sanctions and introduced new ones, Iran launched a low-intensity war against the US and its regional allies. It is suspected of being behind multiple attacks on tankers in the Gulf as well as a drone attack on Aramco facilities in Saudi Arabia.

The Islamic Republic felt increasingly under pressure at home, as the economic situation deteriorated and it was forced to increase fuel prices by almost 200 percent, which sparked mass demonstrations.

On December 27, pro-Iranian Iraqi militias within the PMU attacked an Iraqi military facility, killing an American contractor and injuring several troops. Two days later, the US responded with an air raid on several targets related to Kataib Hezbollah, an Iraqi militia that is part of the PMUs, which resulted in the death of at least 25 of its members.

The situation escalated and on December 31, the US embassy in Baghdad's Green Zone was stormed and its reception area set on fire. The brazen nature of the breach of the heavily fortified diplomatic compound sent a message to Washington which Trump clearly did not get.

This latest violation of Iraqi sovereignty will not only result in greater frustration among the Iraqi public, making the US even less popular, but it will also lead to renewed pressure on the lame-duck Iraqi government to expel the 5,000 American forces stationed there.

Iraqi anger

Since October, Iraq has witnessed a wave of protests against corruption, government mismanagement, and deteriorating living conditions across the south and centre of the country. Protesters have also rejected Iranian interference and support for the government.

Never had Iran's influence in Iraq been so precarious since the 2003 Iraq war. Iranian-affiliated PMUs have been accused of targeting the protesters, who for the most part are their Shia coreligionists. The Iranian consulates in Najaf and Karbala were torched and Adel Abdul Mahdi, the Iraqi prime minister, whom Iran supported, had to resign in the face of the escalating violence against peaceful protests.

Iraq has never faced an intra-Shia crisis on this scale. The US attack, however, will likely undermine the Iraqi protest movement and may reunite Shia forces. While Iraqis may have protested against the PMUs, they would take even more umbrage at the US attacking one of their own leaders who led the fight against the Islamic State of Iraq and the Levant (ISIL or ISIS). The US made al-Muhandis a martyr.

Trump's decision to assassinate him and Soleimani offered a lifeline to the Iranian-affiliated militias, as well as the Islamic Republic, shifting the Iraqi demonstrators' anger from corruption to the brazen violation of national sovereignty.

A potential blowback

With just 10 months left until the US presidential election, Trump seems set to fail on one of his main 2016 campaign promises: To withdraw from American commitments overseas, particularly in the Middle East. After the sacking of the American embassy, his administration announced 750 troops would be sent to the Middle East, with 4,000 more preparing to follow.

This is in addition to 14,000 US personnel who have been deployed to the region since May as a result of an escalation of tensions with Iran, including 3,000 who were dispatched in October after the drone attack on Aramco's oil facilities in Saudi Arabia.

If the security situation deteriorates further, more troops will likely have to be committed. Iran has a number of fronts where it can escalate its efforts against the US and its allies, including Lebanon, Syria, Yemen and the Gulf.

In Iraq, it can intensify the attacks of the PMUs on US troops and facilities. It can also push for the Iraqi government to demand the withdrawal of US forces from the country. Pro-Iranian political parties have already requested this in the past, most recently after Trump visited a US base unannounced a year ago, without meeting Abdul Mahdi in Baghdad. The US attack gives them yet another opportunity to renew this demand.

Apart from the PMUs and pro-Iranian political factions, other Shia forces are also not particularly happy with the US presence in Iraq. Shia leader Muqtada al-Sadr, whose Sairoon coalition won the most seats in the 2018 parliamentary elections, has always been wary of Iranian influence in Iraq and has clashed with pro-Iranian groups, but he has opposed American influence even more. He came to prominence after 2003 by leading his militia in a years-long fight against US forces in Iraq. Several hours after the US attack, he issued a statement mourning Soleimani and al-Muhandis' deaths and ordering his militia, the Mahdi army, to mobilise "to protect Iraq".

As we enter a new decade, the events of the last week demonstrate how the US continues to misunderstand the ramifications of its actions in the Middle East. Trump has given both the beleaguered Islamic Republic and the PMUs the opportunity to shift the narrative of the Iranian and Iraqi protest movements away from them and towards the US. What the Islamic Republic and its allies lost in the deaths of two military commanders will be made up in their martyrdom being used as a source of new legitimacy in Iraq and beyond.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial stance.