As President Obama weighs whether to re-enter the Iraq war, the country’s neighbor, Iran, is looking to step into the void.

U.S. and senior Iraqi officials tell The Daily Beast that Iran is now offering the government of Prime Minister Nouri al-Maliki its army, its spies and highly trained irregular units from its revolutionary guard corps to root out the Sunni insurgency that now threatens Baghdad. Gen. Qassem Solaimani, the commander of Iran’s elite Quds Force, arrived in Baghdad last week with an entourage of military advisers to begin preparations for such a counter-offensive. A member of the Quds Force has already allegedly been killed fighting in Iraq.

While last week a spokesman for Iran’s foreign ministry said his government received no formal requests for military assistance from Iraq’s government, senior Iraqi officials tell The Daily Beast that Iran has offered such support nonetheless.

“The offer to help us with everything we need has been made from the highest levels of the Iranian government,” a senior Iraqi official told The Daily Beast. This official stressed that Iran’s offer to assist Iraq’s fight against the Islamic State of Iraq and the Sham (ISIS) was not conditional on Maliki making any immediate reforms or changes to his government.

The same cannot be said for any assistance Obama may offer to Maliki. Obama himself in brief remarks on Friday said, “Any action that we may take to provide assistance to Iraqi security forces has to be joined by a serious and sincere effort by Iraq's leaders to set aside sectarian differences, to promote stability and account for the legitimate interests of all of Iraq's communities, and to continue to build the capacity of an effective security force.”

A senior Obama administration official Monday told The Daily Beast that the White House is feeling pressure to deal with the Iraq issue. “There is urgency due to the dire situation in Iraq,” this official said. “But the president’s focus is on making the correct decision. Of course the Iranian calculation factors in, but it is one of many, many factors.”

The choice before Maliki now is a stark one and any remnants of the U.S.-Iraq strategic relationship hangs in the balance. While Secretary of State John Kerry said Monday he would be willing to explore U.S.-Iranian cooperation in Iraq in the fight against ISIS, the two countries have been on the opposite sides of the terrorism issue for years.

To this day, Iran is considered the world’s leading state sponsor of terrorism, according to the State Department’s annual report, because of its support for Hamas and Hezbollah. The Treasury Department has also accused Iran—as recently as February—of allowing al Qaeda figures to facilitate the movement of money and personnel to its cells in Syria and south Asia.

Lukman Faily, Iraq’s ambassador to Washington, in an interview declined to discuss any specifics of the Iranian offer to Maliki’s government. But he did say that his government faced a desperate choice.

“We face an existential threat ourselves. We cannot coexist with ISIS,” he said. “Unfortunately, when people are desperate, they will take desperate measures.”

He added, “We will go to whomever we can partner with to deal with the immediate threat.”

Since his visit to Washington in November, Maliki has asked President Obama to conduct drone strikes inside his country against ISIS targets. The Obama administration has publicly brushed off these requests until last week. Kerry on Monday told Yahoo News that air strikes were now under active consideration by the president.

While President Obama was unable to persuade Maliki in 2011 to allow U.S. troops to stay in Iraq past the end of the year or have access to the country’s military bases, the U.S.-Iraqi defense relationship continued nonetheless.

Faily said that today the United States has approved more than $10 billion worth of foreign military sales to Iraq in the coming years. This includes air defense systems and a new batch of F-16 fighter jets scheduled to be delivered to Balad Air Base. That’s significant, because the one thing Iran cannot offer Maliki is a competent Air Force capable of targeting ISIS leaders from the sky.

But American arms sales to Iraq have not stopped Maliki from pursuing a close relationship with Iran. Iran’s government maintains particularly close ties to Iraq’s Shi’ite political parties and has helped finance the political campaigns of Shi’ite leaders it favors. In some cases, the influence from Iran has paid off. Maliki, for example, has allowed Iranian aircraft carrying weapons and personnel for Syrian President Bashar al-Assad’s counter-insurgency to fly over Iraqi airspace over U.S. objections.

Iran’s involvement, though, could backfire. The jihadist group has been getting support in its land grab from local Sunni tribes by exploiting frustrations with the highly sectarian government of al-Maliki. Mideast scholar Michael Rubin of the Washington-based think tank the conservative American Enterprise Institute said there are clear dangers in an Obama administration dealing with Iran over Iraq. “Just because firemen and arsonists have a shared interest in fires does not make them natural allies,” he warned.

“The problem isn’t the Iranians going in, but rather getting them out. Just think of poor Lebanon, still suffering under the yoke of Lebanon 32 years after the creation of Hezbollah and 14 years after Israel withdrew,” he added.

In Syria’s neighboring civil war—Iranian military involvement either directly or through Lebanon’s militant Shia movement Hezbollah, Tehran’s proxy—has proven crucial in tilting the battlefield in favor of Iran’s ally President Bashar al-Assad. Last summer, Hezbollah assisted Assad forces in the re-capture of the strategic city of Qusair. Since then, Iran’s revolutionary guardsmen have acted as advisers and trainers.

Advisory work and training will likely be among the roles Iran’s forces will focus on in Iraq—and the Iraqi officer corps sorely needs it, observed military analyst Charlie Cooper of the London-based Quillam Foundation. He said a crucial factor in the heavily outnumbered jihadists being able to over-run Mosul last week was the failure of Iraqi officers to stand their ground. “Senior officers were quick to flee. This left a disgruntled population with about 30,000 Iraqi soldiers who were, for want of a better phrase, abandoned by their officers.” ISIS in Mosul reportedly took more than 4,000 Iraqi soldiers prisoner.

Cooper predicts that ISIS will maintain its insurgency in towns in the Tigris valley north of Iraq’s capital of Baghdad while it consolidates its hold on territory contiguous with its strongholds in eastern Syria. But he doubts the ISIS aim is to assault Baghdad, despite jihadist claims.

“They’re very close to Baghdad now, but because of the sectarian make-up of any territories that they’ve not yet taken, it will not be as easy to consolidate control, if they continue to expand,” he says. “What they are feeding off right now is Sunni discontent towards Baghdad. If, however, they attempt to invade Baghdad, I’d imagine that they would have to focus almost exclusively there.”

Faily said when it comes to ISIS, Iranian and American interests aligned. “What we are saying is the international community needs to work with each other to contain the spread of ISIS. Within that context, a U.S.-Iranian focus on ISIS is welcomed. One is a neighbor, and one is a strategic partner.”

Because Faily is an ambassador in Washington, however, and not Tehran, he is most interested in what Obama will decide. “The issue we have now is the critical acid test for our relationship,” Faily said. “We have chosen the United States as our strategic partner ... Don’t make us desperate. There is a void. We ourselves cannot fill this void.”

The ambassador will find out in the coming days whether Iraq can count on its strategic partner to fill that void.

—with additional reporting by Jamie Dettmer in Erbil.