meaning the future of each country's role in Iraq may be in question.

AHMAD AL-RUBAYE | AFP | Getty Images

The final results of Iraq's first post-Islamic State (ISIS) election, held last weekend, have revealed a shock win for controversial anti-American cleric Muqtada al-Sadr. Now in a position to potentially determine much of the country's future, the Shia leader, who has railed against both U.S. and Iranian influence, could dramatically change the landscape for major powers that have invested heavily in Iraq. A firebrand religious leader with millions of loyal followers, Sadr gained infamy shortly after the 2003 U.S.-led invasion by directing deadly attacks against American troops with his Mahdi Army, which also attacked Iraq's Sunnis. Lately, he has shifted his focus to anti-corruption campaigns and advocating for Iraq's poor. But he's in the rare position of opposing both the U.S. and Iran — several of his election rallies triggered chants of "Iran out!" among his followers, voicing the desire for an Iraqi state run by Iraqis.

America's role in the balance

"Is it the end of America's presence? It's too early to say," Robert Ford, who served as political counselor to the U.S. embassy in Baghdad from 2004 to 2006 and was later the last U.S. ambassador to Syria, told CNBC in a phone call. "Were I giving advice (to Washington), I'd say don't panic yet. We'd be much better off giving the Iraqis some space and dealing with them when they are ready to deal," he said. Otherwise, Ford warned, the Sadrists could view U.S. involvement as malign manipulation. American diplomats in Iraq are already in discussions with Iraqi politicians, and the Donald Trump administration seems intent on keeping troops there to push back on Iran. Sadr agreed to a cease-fire in his fight against the U.S. a decade ago — although if Washington were to launch another large-scale occupation, regional experts warn that could change.

A masked interpreter, left, patrols the streets of Baghdad with a US Army unit. Tom A. Peter | The Christian Science Monitor | Getty Images

America's long-term presence in the country remains uncertain, and Iraq's parliament in March overwhelmingly voted to demand a timetable for a withdraw of coalition forces. Sadr could demand a timeline for a U.S. withdrawal or significant concessions on the U.S. role in Iraq, something his followers strongly support. More than 5,000 troops remain in Iraq following the defeat of ISIS there late last year. But while the cleric clearly opposes the presence of U.S. troops, he hasn't voiced an issue with civilians, including the continued staffing of the U.S. embassy, Ford said. He suggested that this may be where Washington should focus, while maintaining a military training mission within the embassy's rubric.

Once [the Americans] get around to the fact that this is a region where warlords and militia leaders become politicians — and he's also a cleric and has this legitimacy — it's hard not to deal with him. Renad Mansour Iraq research fellow at Chatham House

It's all about optics, Ford stressed. "How you make adjustments to minimize that American role, even if you try to keep an American role, that's going be the art the Trump administration is going to have to work on." In any case, he added, "I wouldn't be building a brand new $10 million military facility anytime soon." Like it or not, the Americans will have to try and work with this new reality, said Renad Mansour, an Iraq-focused research fellow at Chatham House. "Once they get around to the fact that this is a region where warlords and militia leaders become politicians — and he's also a cleric and has this legitimacy — it's hard not to deal with him."

Iran watching closely

Meanwhile, how the Iraqi government is formed in the coming months is something Tehran will be monitoring very closely.

Iraqi Shiite cleric and leader Moqtada al-Sadr (C-L) shows his ink-stained index finger and holds a national flag while surrounded by people outside a polling station in the central holy city of Najaf on May 12, 2018 as the country votes in the first parliamentary election since declaring victory over the Islamic State (IS) group. HAIDAR HAMDANI | AFP | Getty Images

Sadr didn't personally run for prime minister, so he can't actually take up the role. But depending on the formation of parliament — normally, a complex 90-day process requiring negotiations and compromises among political blocs — he could play a dominant role in choosing who does, and that could threaten Iran's interests. Most bets were on current Prime Minister Haider al-Abadi to win, a leader credited with leading the fight against ISIS and effectively balancing ties with the U.S. and regional neighbors. His positive relationship with Washington gained him distrust from Tehran. But Abadi finished in a meager third place behind the Iranian-backed militia leader Hadi al-Amiri, head of the Badr Brigade, an organization created by Iran during the 1980s to fight Saddam Hussein in the Iran-Iraq war. Amiri was among Tehran's favorites to win — and this dynamic could create a rift in parliament between Iran loyalists and Sadr supporters.

New alliances

In recent years, Sadr has pledged a commitment to relinquish sectarianism. He's recently reached out to Sunni Gulf neighbors like Saudi Arabia and the UAE, and projected pan-Iraqi nationalism by filling his party with candidates from across Iraq's demographic spectrum. Sadr's party, the Sairoon Alliance, is an unusual mix of secular Shia and Sunni elements as well as Iraq's community party. "He's not necessarily being antagonistic with the U.S.," said Mansour. "And he has actually, since meeting with (Saudi) Crown Prince Mohammad Bin Salman, proven to be an asset against Iran."

Iranian Quds Force commander Qassem Soleimani (C) attends Iranian supreme leader Ayatollah Ali Khamenei's (not seen) meeting with the Islamic Revolution Guards Corps (IRGC) in Tehran, Iran on September 18, 2016. Pool | Press Office of Iranian Supreme Leader | Anadolu Agency | Getty Images

Bin Salman and other Gulf allies are expanding their engagement with Baghdad in an effort to counter the presence of their Iranian arch-rivals. "A strong result for Sadrists is not great news for the U.S., but it is not the worst news either," despite the violent history between the two, according to Marcus Chenevix, Middle East and global politics researcher at TS Lombard. "Sadr is relatively independent of Iranian control, much more so than Amiri. So this will result in a more difficult relationship with the Iraqi government, but it will not create a rift between Iraq and the West." "Overall," he added, "I would say that this is a poor result for Iran."

A violent history

Iraq's deep sectarian divisions, which have long fueled violence in the country, serve as a major obstacle to security and reconstruction. A leader who can effectively bridge these divides will be crucial for Iraq's stability. Many fear that politicians loyal to Iran like Amiri, the Iran-backed militia leader who won the second-most votes, could exacerbate sectarian tensions that risk enabling the resurgence of ISIS. Iran's interests in Iraq can be traced back to the 1980s Iran-Iraq war, a bloody conflict marked by trench warfare and chemical weapons that saw hundreds of thousands dead on both sides. When Saddam was toppled and the country fell into chaos, Tehran saw an opportunity: it would gain control of its political system and economy to such an extent that Iraq could never again pose a military threat. And through its geographic and religious links to the country, Iran saw Iraq as a new launch pad from which it could extend its influence throughout the region, more easily accessing its proxies in Syria and Lebanon. As the U.S. withdrew from Iraq in 2011, this proved easy. And Shia militias funded and trained by Iran — the Popular Mobilization Forces — later played a pivotal role in defeating ISIS, cementing its clout in the country.

Fighters of Hashed Al-Shaabi (Popular Mobilization units) flash the victory gesture as they hold upside down a banner bearing the logo of the Islamic State (IS) group, during the advance in the town of Tal Afar, west of Mosul, after the Iraqi government announced the launch of the operation to retake it from IS control, on August 26, 2017. AHMAD AL-RUBAYE | AFP | Getty Images

Now, the Tehran-founded Badr Brigade controls Iraq's interior ministry, commanding a force of 37,000 federal police officers. And Iranian proxies last year gained control of the oil-rich Kirkuk province, after helping Baghdad wrest it from the Kurds in the wake of Kurdistan's failed independence referendum.

'A potential showdown'

"Sadr has long had a difficult relationship with some of the Iranian-backed militias like Badr," Ambassador Ford said. "That means that whatever official Iranian presence is in Iraq, I suspect Sadr will want that out too." But although Sadr has clashed with Iran, it'll be much more difficult to limit Tehran's influence given its entrenched place in Iraqi politics — "setting the stage for a potential showdown between Sadr and Tehran over Iraq's future," said Ryan Turner, senior risk analyst at PGI Group. Feisal al-Istrabadi, the founding director of Indiana University's Middle East Studies Center who served as Iraq's ambassador to the UN from 2004 to 2007, warned against a divorce in U.S.-Iraq engagement. "I don't think any government would have wanted a relatively sizeable U.S. presence in Iraq," Istrabadi told CNBC. "My hope, however, is that the mistake of 2011 will not be repeated," he said, alluding to the Obama administration's withdrawal of troops, after which even intelligence cooperation and training ceased. The ensuing power vacuum was blamed for both Iran's expanded power and the rise of ISIS a few years later. "I hope the Iraqis and Americans have learnt what a colossal mistake that was and will eschew the same errors going forward."

Reconstruction works continue in Mosul, Iraq after 9 months long anti Daesh operations on January 25, 2018. Hemn Baban | Anadolu Agency | Getty Images