Billions of dollars in recently pledged investment from Saudi Arabia and its neighbors may serve as a tool to meet both of these ends, but Iraq's upcoming election could threaten that — depending on who comes out on top.

Iraqis go to the polls this weekend in their first election since defeating the Islamic State (ISIS), with nearly every aspect of the country's future on the line: its economy, reconstruction, terrorism, sectarian reconciliation, stability, and which international powers will wield the most influence.

The latter is in particular focus for Saudi Arabia and the U.S., who view Iran's fortified presence in Iraqi politics as a direct threat to their interests and to regional stability. All of the frontrunners in the leadership contest have ties to Tehran, but those that are particularly loyal to the Islamic Republic and could effectively force out U.S. and Sunni Gulf involvement in Iraq.

Hemn Baban | Anadolu Agency | Getty Images

Reconstruction works continue in Mosul, Iraq after 9 months long anti Daesh operations on January 25, 2018.

Iran's geographical, cultural and religious ties to Iraq — particularly much of its Shia population — as well as its role in the anti-ISIS fight, make it a heavyweight in the country. Meanwhile, its regional arch-rival Saudi Arabia has just started its engagement with Baghdad, recently pledging $1.5 billion in reconstruction funds and making a series of diplomatic overtures.

Iran: Wielding influence through pro-Tehran candidates

Iraq's population is roughly 65 percent majority Shia Muslim, and the role of prime minister has been reserved for a Shia ever since the fall of Saddam Hussein's Sunni government during the 2003 U.S. invasion.

While several parties and candidates are running, the pack is led by the current prime minister, Haider Al Abadi, who is seen as the most pro-Western and who the U.S. hopes will win re-election. Abadi has been praised for running on a pan-Iraqi, anti-sectarian platform, reaching out to Sunni neighbors like Saudi Arabia and working across religious sects.

His primary competition is former Iraqi prime minister Nuri Al Maliki, who is often blamed for the sectarian rule that disenfranchised many Sunnis and led to the empowerment of ISIS. Heavily backed by Iran, Maliki still remains one of the most powerful politicians in the country.

Another potent contender is Hadi Al Amiri, firebrand leader of the Badr Organization that is a part of the Iranian-funded Popular Mobilization Forces (PMF), the Shia paramilitaries that played a key role in defeating ISIS but who have been accused of sectarian atrocities by Iraq's Sunni and Kurdish communities.

Threats to U.S. interests

Both Maliki and Amiri are viewed as conduits through which Iran can exercise political power, said James Jeffrey, former U.S. ambassador to Iraq from 2010 to 2012 and a fellow at the Washington Institute for Near East Affairs.

"Iran is doing everything they can to block Abadi, who they see as too pro-American," Jeffrey told CNBC in a phone call. Through Maliki or Amiri, "Iran will try to ease the U.S. out of Iraq, and diminish our influence through parliament to push out U.S. troops." More than 5,000 U.S. troops remain in Iraq.

The PMF was officially made a part of the Iraqi military the same month, something that also worries Washington — multiple PMF commanders have issued threats against U.S. troops in the country.

Saudi rapprochement: Old neighbors, new friends

Saudi Arabia has been steadily expanding its engagement with Iraq's government, which is a big deal — the two countries had no diplomatic relations for 24 years following Saddam Hussein's invasion of Kuwait in 1990. Late 2017 saw the first flight between Riyadh and Baghdad in 27 years, and now the kingdom has opened up a consulate in Iraq's southeastern city of Basra while several Saudi businesses have set up offices in Baghdad.

Iraqi officials estimate $100 billion will be needed to rebuild the country after its bloody three-year offensive against ISIS, which swept one-third of the country in 2014. Allies pledged $30 billion for reconstruction during a donor conference in February, far short of the target — but one-third of that came from Sunni Gulf states. Those funds are expected to go toward much-needed investment in sectors like housing, energy, and transportation.

Iraq's post-ISIS reconstruction will be vital to avoiding a return to future conflict. But those investment dollars may become a victim of the Saudi-Iran rivalry, said Nicholas Fitzroy, Iraq analyst at the Economist Intelligence Unit.

"Abadi is largely accepted across the international community and his victory would be least likely to jeopardize investment," he said. "Should Amiri or Maliki head the government, the Gulf countries, and Saudi Arabia in particular, would be much more reluctant to commit funds, given both candidates' close links to Iran."

Meanwhile, as tensions between the Saudis and Iranians heat up, Abadi has said he does not want them turning Iraq into their battlefield, as has happened to varying extents through proxy conflicts in Syria and Yemen.

Not going anywhere

While Riyadh's budding friendship with Baghdad may be making Tehran uncomfortable, it's still set to remain a potent force in Iraqi politics for the foreseeable future. "Although Saudi Arabia and other Gulf states are likely to increase their influence in Iraq by providing reconstruction funds, in the long run, Iran will retain a significant influence over its neighbor," Fitzroy said.

But a win for Abadi, who aims to rein in Iranian-backed bodies like the PMF, could potentially temper Tehran's strength. According to Ryan Turner, a senior analyst at risk consultancy PGI Group, "Over the long-term, the growth of a non-sectarian national identity could diminish Iran's influence in the country."

The most positive election outcome for international private investors "is one which is as inclusive of Iraq's various ethnic and political factions as possible," said Hasnain Malik, head of equities research at frontier markets investment bank Exotix Capital.

Inclusion, he stressed, is vital for stability and thereby investor confidence. Neglecting that delicate balance risks pulling the country back into the violence from which it's only started to recover.