A battle between the Islamic State group and Iraqi government forces in an obscure Iraqi town is helping highlight an issue that may derail the chance of a nuclear agreement between Iran and the international community.

Clashes in Jurf al-Sahkr, a town located between Baghdad and Karbala, last week reportedly killed dozens of civilians. Islamic State militants were pushed out of the town completely, senior Iraqi officials quoted by state media said, by militias with connections to Iran. Those militias are in essence acting as some of the strongest “boots on the ground," according to sources closely connected to the matter. Analysts said the Iranian-backed militias are indirectly supported by the U.S., in a relationship that could alter the course of the current negotiations on a deal to suspend economic sanctions if Iran agrees to halt its nuclear program.

“Iran and the U.S. have been tactically working together for a long time,” said Alex Vatanka, a senior fellow at the Middle East Institute in Washington. “The Iranians and Americans are indirectly working together to fight ISIS.”

But any deal to barter Iranian support against ISIS in exchange for more lenient terms in an agreement on the Iranian nuclear program would meet with implacable opposition from the staunchest U.S. ally in the Middle East, Israel.

The deadline for a possible agreement on the future of Iran's nuclear program is two weeks away, and the international community is still not sure whether there will be a deal.

"Israelis are worried," Vatanka said, referring to the long-standing animus between Israel and Iran, which is openly hostile to the Jewish state. "How can the U.S. Congress sign up to be in some sort of long-term cooperation with Iran when one of our biggest allies is Israel?"

In Prime Minister Benjamin Netanyahu's mind, if Iran develops even one nuclear weapon, it will have crossed a red line because "Iran would be the state that would attack Israel," said Robert Kelley, a fellow at the Stockholm International Peace Research Institute and a former Iraqi nuclear weapons investigator for the International Atomic Energy Agency.

Now, American loyalty to Israel is colliding with the possibility that Washington might acknowledge that Iran, officially an adversary of the U.S., is helping Americans fight the Islamic State in Iraq.

The U.S. has known of Iranian influence in Iraq for years. Under President George W. Bush, the U.S. government "revived charges that the Iranian leadership was involved in the killing of American soldiers in Iraq," Seymour Hersh wrote in a 2008 article in The New Yorker. Retired Adm. William Fallon told Hersh that during his time at the U.S. Central Command, which is responsible for operations in the Middle East, "Iranians were funding every entity inside Iraq. It was in their interest to get us out, and so they decided to kill as many Americans as they could."

Pictures that surfaced after the fighting in Jurf al-Sahkr showed palm trees that had been cut down and burned lying charred on the ground, and motor vehicles sitting upside down, their windows smashed and interiors destroyed. Shiite militias had burned the trees down to create paths safe from land mines. The defeat of ISIS in Jurf al-Sahkr was one of the few victories the Iraqi military has gained in recent weeks and underscored the effectiveness and strength of the Iran-backed militias.

Burned vehicles lie on the side of the road in Jurf al-Sakhr, Iraq (shot through car window, so a bit blurry) pic.twitter.com/OHaAI8zUpa â€” W.G. Dunlop (@wgdunlop) November 9, 2014

Since ISIS began its march toward Baghdad in June, the militant group has taken over key, oil-rich towns and now controls a stretch of land from Aleppo in Syria all the way to the suburbs of Baghdad. The Shiite militias recruited by the central government and backed by Shia-majority Iran are basically the only forces preventing ISIS from entering the capital.

#Iraq H. Qassem Soleimani hugging h. Hadi Al-Amiri. Celebrating the fall of #Jurf_Al_Sakhr last week. pic.twitter.com/poMHkOwVP5 â€” Green lemon (@green_lemonnn) November 5, 2014

(Pictured above, Qasem Soleimani is the commander of the Quds Force, which is part of Iran's Islamic Revolutionary Guard Corps and is leading Shiite militias in Iraq).

Despite the key role Shiite militias, such as Saraya al-Salam and Asai’b ahl al-Haq, play in the fight against ISIS in Iraq, U.S. senior officials have not publicly acknowledged Iran’s influence in the country. In fact, State Department spokeswoman Jen Psaki said Monday that Iran contributed to “instability in the region,” adding that the U.S. government was aware of Iranian operatives inside Iraq for “training and advising” purposes but that it was “not something we are encouraging.”

Neither the U.S. government nor Iran will acknowledge each other’s presence in Iraq as positive because “the politics of the situation is so toxic, but the fact of the matter is that they are" cooperating, Vatanka said.

The parties to the nuclear talks are currently operating under an agreement known as the Joint Plan of Action, signed by the negotiating group known as P5+1 -- the five permanent members of the U.N. Security Council plus Germany. The JPOA called for a temporary freeze of parts of Iran's nuclear program in exchange for reduced economic sanctions. The deal was signed in November 2013, and the implementation of the agreement began in January 2014. It was supposed to end in July with a final deal on the future of Iranian sanctions, but that term has been extended until Nov. 24.

Last week, the Wall Street Journal revealed that President Barack Obama wrote Iran’s Supreme Leader Ayatollah Ali Khamenei in mid-October urging cooperation between the two countries in the battle against ISIS. Obama said in the letter that the U.S. would cooperate with Iran only if it agreed to scale back its uranium enrichment, as outlined in the JPOA. If Iran cooperates, the U.S. could ease economic sanctions.