Tehran has much at stake in the tumult afflicting Iraq, expending substantial military and financial aid to shore up its strategic ally in Baghdad, while fortifying its own borders against fighters of the Islamic State of Iraq and the Levant (ISIL), Iranian and Iraqi analysts say.

Until the fall of Iraq's second largest city of Mosul to ISIL last June, Iranian officials, according to analysts, remained largely quiet about the extent of that aid, even as Tehran rapidly intervened to provide arms, training and aerial support to Iraqi security forces, militias and Kurdish Peshmerga fighters.

It wasn't until fall 2014, amid reports of US overtures to Iran for open cooperation in battling ISIL if a deal is struck over Tehran's contested nuclear programme, that Iran began publicly touting its heightened role in Iraq on a much larger scale.

Now, despite recent reports of a "noncommittal" response from Iran's Supreme Leader to Washington's suggestion of cooperation against ISIL, Iraqi and Iranian analysts say Iran's public face of hesitation belies the reality of its activities on the ground. Indeed, Iran's willingness to absorb - and publicly account for - the recent deaths of senior Iranian military commanders inside Iraq, signifies its shift from a traditionally quiet - but pervasive - presence to one of outright public intervention in Iraq's internal security, analysts say.

RELATED: Iran advisers boost anti-ISIL battles in Iraq

Iraqi officials find themselves wavering between feelings of gratitude for Tehran's immediate provision of arms and support, and anxiety that Iran's increased involvement in Iraq will be difficult to retrench once the fighters of ISIL are gone.

"The Iraqi government is very weak. The hesitation on the Arab side, the US and western side has allowed Iran to … take advantage of the ISIL crisis to strengthen its grip on Iraq," said Mustafa Alani, director of security and defence studies at the Gulf Research Centre in Dubai.

"Iranian intervention could be seen [by Iraq] as a necessity in the beginning, but this sort of influence will be hard to exit from again."

According to Mowaffaq al-Rubaie, Iraq's former national security adviser, Iran has taken a lead in arming, advising and leading Iraqi Shia militias, also known as the Popular Mobilisation Forces, and has given crucial support to the Iraqi Security Forces and Iraqi Kurdish Peshmerga soldiers in the resurgent battle against ISIL.

Tehran has also provided aerial support, returning eight refurbished Su-25 Frogfoot attack planes to Iraq, co-piloted with Iraqi airmen for training, just weeks after Mosul's fall, Rubaie said.

"The Iranians were the first to step in and physically save Baghdad from falling. We're talking within 24 to 48 hours … advising, equipping and training Iraqis, and also providing analysis and intelligence," said Rubaie.

"Even those Iraqis who are not pro-Iran, and might be opposed to asking for help from Iran, won't reject help," if it's offered, he said.

Last November, Iranian fighter jets carried out strikes against ISIL fighters in Iraq's eastern Diyala province. Later that month, the commander of Iran's Quds Force, Qassem Suleimani, helped lead Iraqi Kurdish fighters, Shia militias and Iraqi Security Forces as they fought to take back towns from ISIL fighters in Diyala.

The reinforcement of a strong ally in Baghdad and the fortification of its own borders are at stake for Iran. Protecting its southwestern province of Khuzestan, which is home to much of Iran's oil production, and securing Iraq's eastern Diyala province, which lies along the route from Iran's Kurdish province of Kermanshah to Baghdad, are key.

RELATED: Iraq's Sunnis may seek Iran's help against ISIL

Other priorities include rolling back ISIL fighters from Baghdad's suburbs and securing the route from the Iraqi capital to Samarra (home to the al-Askari Shrine revered by Shia Muslims worldwide) in Salahuddin governorate.

Tehran has recently seen two senior military commanders assassinated in Iraq, during what Iran-based analysts say were targeted attacks by ISIL fighters.

General Mehdi Norouzi, who according to Iranian media reports was killed on January 10 amid clashes with ISIL in Samarra, is the second senior commander from Iran's Revolutionary Guards Corps to die in Iraq in the last two months.

In December, Iranian Brigadier General Hamid Taqavi, who analysts say was helping train Iraqi security forces as well as militia fighters, was killed by sniper fire in Samarra, 121km north of Baghdad.

They're keeping the fight outside Iran … protecting their borders. Iraq is a buffer zone against military attack. For any attack on Iran, you'd have to go through Iraq or Afghanistan, which is why it has been imperative for Iran to maintain a presence in both countries. Veteran Tehran-based analyst who wished to remain anonymous

"They're keeping the fight outside Iran … protecting their borders," said a veteran Tehran-based analyst. "Iraq is a buffer zone against military attack. For any attack on Iran, you'd have to go through Iraq or Afghanistan, which is why it has been imperative for Iran to maintain a presence in both countries."

Extensive US-led coalition air strikes against ISIL positions are also credited with helping turn the tide in favour of Iraqi forces.

The "non-kinetic" price Iraq will have to pay in the long run for such massive dependence on external aerial and military support is becoming increasingly worrisome for Iraqi officials.

"Iran will be in charge of the ground and land, the US will be in charge of the sky, and [Iraq's] commander in chief will be the interlocutor," said a Baghdad-based analyst who is close to the Iraqi government. "Iraq's sovereignty will be in jeopardy. If you don't command the ground or the sky, then what are you commanding?"

The strength of Iran's influence in Iraq once ISIL is rooted out will depend on how directly involved Washington and other Arab states ultimately decide to be, the Baghdad-based analyst said.

Though regional Arab countries have been keen to limit Iranian influence in a post-ISIL Iraq, their support has remained largely limited to participating in the US-led coalition air strikes.

RELATED: Hezbollah chief urges Middle East to unite against ISIL

As Iran gains traction on the ground, the adherence of many militias, who had a hand in thousands of deaths during Iraq's 2006-2007 sectarian civil war, to Baghdad's central authority once ISIL is routed out, could largely be up to Tehran.

"Arab involvement would help within an international framework … to strengthen the central state authority," Alani said.

Iraqi officials recently hailed an announcement that the UAE may provide 10 Mirage fighter planes to the Iraqi Air Force by March, along with an unspecified number of light strike aircraft for border patrol and anti-insurgency operations. Iraqi officials told Al Jazeera that the UAE is slated to also provide training to Iraqi pilots.

"This is a very positive move [which] will cement a very strong bond on the security side between Iraq and the UAE," said Rubaie, who is now a member of Iraq's Parliament.

Iran-based analysts admit Tehran will vie to maintain extensive ties within Iraq's security apparatus and look to expand its economic involvement in a post-ISIL Iraq.

However, an outright military presence within Iraq's borders is something Tehran doesn't want long-term, said political scientist Hermidas Bavand.

Iran's decision to abandon former Prime Minister Nouri al-Maliki last year in favour of a new premiership for Haidar al-Abbadi could reflect the start of a more pragmatic approach towards power sharing with Iraq's Sunnis, at least for now.

"We understand the bitter message from American involvement in Afghanistan and Iraq; it was successful in the beginning, but … deep involvement means we are going to absorb great difficulties financially, socially and politically," said Bavand, speaking by phone from Iran.

"We should be involved in a more marginal way. Otherwise, it's going to become a quagmire."