With a rapidly deteriorating security situation in Iraq, the Obama administration is considering the possibility of collaborating with Iran to help the Iraqi government thwart an Islamist advance, US officials said.

The US may use nuclear talks slated to start Monday as a venue to broach the subject, the Wall Street Journal reported, citing anonymous officials.

Iranian President Hassan Rouhani has said that Iraq had not asked for Tehran’s help in pushing back the assault by the Islamic State of Iraq and the Levant jihadist group, but surprised observers by adding that Iran may “think about” cooperating with Washington, with whom it has not had diplomatic relations for more than three decades.

Iran has been a staunch supporter of the ruling Shiite government in Iraq and Prime Minister Nouri al-Malik.

The possibility of US-Iran discussions came as the crisis entered its second week, at a point when some in the US see working with the Islamic republic as the lesser of two evils.

Senator Lindsey Graham, R-S.C., speaks in December during a Capitol Hill news conference in Washington, D.C. (photo credit: AP/Ann Heisenfelt)

Senator Lindsey Graham (R-SC) has advocated preparing an authorization of military force against Iran. (photo credit: AP/Ann Heisenfelt)

“Why did we deal with Stalin? Because he was not as bad as Hitler,” Sen. Lindsey Graham (R., S.C.) said Sunday on CNN. “The Iranians can provide some assets to make sure Baghdad doesn’t fall.”

However, some US defense officials are more wary of trusting Iran to get in step with implementing US goals in Iraq.

While Iran’s main interests lie in protecting the Shiite-dominated government, the US has pushed for a more inclusive government and Sunni-Shia reconciliation as a condition for aid in the fight. Analysts say that ISIL has been able to capitalize on the sectarian divisions to garner support in the Sunni Arab-majority north and west of Iraq.

“This is a case where the enemy of our enemy is still our enemy,” US defense official who has worked extensively in Iraq said, according to WSJ. “Any shared interests in Iraq are limited.”

The situation in Iraq came to a head when, after days of unrest elsewhere in the north and west of Iraq, ISIL militants launched an assault on the country’s second-biggest city Mosul, and swiftly moved down to Tikrit, executed dictator Saddam Hussein’s hometown.

Iraqi forces performed poorly early on, abandoning vehicles and positions and discarding their uniforms, with militants reaching within 80 kilometers (50 miles) of Baghdad’s city limits in just four days.

Baghdad’s embattled forces, which have done better in recent days, will be joined by a flood of volunteers after a call to arms from top Shiite cleric Grand Ayatollah Ali al-Sistani, but a recruitment center for volunteers came under attack on Sunday, leaving six people dead.

UN-Arab League envoy for Syria Lakhdar Brahimi speaks during a news conference after closing the second round of negotiation between the Syrian government and the opposition at the European headquarters of the United Nations, in Geneva, Switzerland, Saturday, February 15, 2014 (photo credit: AP/Keystone, Salvatore Di Nolfi)

UN-Arab League envoy for Syria Lakhdar Brahimi speaks during a news conference after closing the second round of negotiation between the Syrian government and the opposition at the European headquarters of the United Nations, in Geneva, Switzerland, Saturday, February 15, 2014 (photo credit: AP/Keystone, Salvatore Di Nolfi)

Lakhdar Brahimi, the former UN and Arab League envoy to Syria, told AFP the international community’s neglect of the conflict in Syria had precipitated the Iraq crisis.

“It is a well-known rule: a conflict of this kind [in Syria] cannot stay confined within the borders of one country,” said Brahimi, who resigned as UN-Arab League representative to Syria last month.

Meanwhile, Western embassies began evacuating staff from Baghdad Monday despite Iraq’s claim it was repelling militants who have captured vast amounts of territory in a lightning offensive that has shaken regional stability.

ISIL militants are also said to have killed scores of Iraqi soldiers as they pushed an advance on the capital, a “horrifying” massacre that has drawn international condemnation.

The diplomatic evacuation, confirmed thus far by the United States and Australia, was coupled with the announcement from Washington that the country’s sprawling embassy — which sits in Baghdad’s heavily-fortified Green Zone — would receive even more security.

It was unclear how many American embassy staff would be evacuated from the mission, but State Department spokeswoman Jen Psaki said they would be “temporarily relocated” to US consulates in the southern port city of Basra, and the northern Kurdish regional capital of Arbil, both of which have been insulated from the recent unrest.

Others would be flown to the US embassy in Amman, Psaki said, citing “ongoing instability.”

The move flew in the face of Iraqi government claims that it was making progress retaking territory from militants, who currently hold most or parts of four provinces north of Baghdad.

Iraq said on Sunday that security forces had killed 279 militants, and said soldiers had recaptured two towns north of Baghdad.

Officials added that security forces and tribal fighters repelled a militant assault in the strategic town of Tal Afar, which provides a critical corridor for militants to access conflict-hit Syria.

Militants took control, however, of the Al-Adhim area in Diyala province.

But as troops began to push back against militants, evidence of brutal violence against members of the security forces emerged.

An image uploaded on June 14, 2014 on the jihadist website Welayat Salahuddin allegedly shows militants of the Islamic State of Iraq and the Levant (ISIL) executing dozens of captured Iraqi security forces members at an unknown location in the Salaheddin province. (photo credit: AFP/HO/Welayat Salahuddin)

An image uploaded on June 14, 2014 on the jihadist website Welayat Salahuddin allegedly shows militants of the Islamic State of Iraq and the Levant (ISIL) executing dozens of captured Iraqi security forces members at an unknown location in the Salaheddin province. (photo credit: AFP/HO/Welayat Salahuddin)

The US condemned a massacre in which ISIL militants appear to have killed scores of soldiers around the conflict-hit city of Tikrit, while the burned bodies of 12 policemen were also found in the town of Ishaqi.

Photos posted online were said to show jihadists summarily executing dozens of captured members of the security forces in the Tikrit area, with tweets attributed to ISIL claiming they had killed 1,700 in all.

The photos and the claims could not be independently verified.

“The claim … is horrifying and a true depiction of the bloodlust that these terrorists represent,” Psaki said.

Washington has also deployed an aircraft carrier group to the Gulf as US President Barack Obama said he was weighing “all options” on how to support the Iraqi government.

But he has ruled out a return to Iraq for US soldiers, who left the country at the end of 2011 after a bloody and costly intervention launched in 2003.