Updated

Sworn enemies Israel and Hamas may have found the one thing that can unite them: The threat of ISIS taking over Gaza.

Hamas, the U.S.-designated terrorist organization which controls the Islamic enclave in Israel and which fought a vicious 50-day war against Israel last summer, is desperately trying to stop ISIS from gaining a foothold within its territory. In recent weeks, jihadi groups loyal to ISIS have exchanged gun and rocket fire with Hamas authorities, planted bombs in public buildings and threatened an all-out war with the Gaza government. Hamas reportedly blew up a mosque believed to be a base for ISIS loyalists and has detained significant numbers of suspects.

“Hamas is brutal enough and determined enough to meet that challenge.”

— Yoram Schweitzer, Institute for National Security Studies

“In light of Hamas’ latest action, we renew our allegiance to [ISIS leader] Abu Bakr Al-Baghdadi and call on him to strengthen his influence, to open up a war in Palestine in order to unite together in a war against the Jews and their accomplices,” a group calling itself Supporters of the Islamic State in Jerusalem said in a statement last month after the mosque in the central Gaza section of Deir Al-Balah was destroyed.

The statement demanded that Hamas release all ISIS loyalists and was followed days later by a bombing near Hamas' security headquarters.

ISIS has now expanded beyond Iraq and Syria and into Yemen, Libya, Egypt and Somalia. Although Palestinian leaders refuse to publicly acknowledge an ISIS presence threat in Gaza, the group’s black flag is now often seen there.

The developments have Hamas and Israel, which sees an ISIS takeover of Gaza as a bigger threat than Hamas, reportedly talking through back channels about how to squeeze out ISIS, a collaboration that some commentators say could be the basis for possible détente between sworn enemies. Any potential agreement, informal or otherwise, does not appear imminent, but there is a growing belief that it remains a possibility.

“I know that people from Hamas have expressed more and more the concept of long-range ‘hudna’ [truce] with Israel,” regional terror expert Yoram Schweitzer of the Tel Aviv-based Institute for National Security Studies told FoxNews.com. “Because of the dire straits in Gaza as a consequence of the last operation there, Hamas has to carry the burden of caring for the people and is considering pushing for a kind of hudna in return for Israeli concessions.”

Late last month senior Hamas official Ahmad Yousef told Ma’an, the Palestinian news agency, that European officials were acting as intermediaries with Israel, but that things would only begin “moving ahead” once the new Israeli government was sworn in. That swearing in ceremony took place last Thursday evening.

“As you can imagine, we are following developments within the Gaza Strip and also in the Sinai Peninsula very, very closely, and not only us, also the Egyptian authorities,” Emmanuel Nahshon, spokesman for Israel’s Foreign Office, told FoxNews.com.

Hamas is under pressure from the densely populated strip's 1.8 million residents to rebuild following the damaging 2014 conflict. Billions in pledges from Arab nations have failed to materialize and a lack of jobs and basic services continues to plague Gaza. Many smuggling tunnels from the Sinai Peninsula, once a source of black market goods, have been blown up or flooded by Egyptian forces who say they have been used by ISIS and its affiliates to mount attacks from within Gaza.

While Israel could conceivably work with Hamas to stop ISIS, Egypt likely sees little difference between the two terrorist groups.

“Egypt sees Hamas as part of the Muslim Brotherhood which they see as their venomous enemy,” says Schweitzer. “They see Hamas playing a significant role in the hardship Egypt is enduring from the Sinai and they know that Hamas enables people from these organizations to find refuge in Gaza. They see Hamas as somebody who needs to be removed from power.”

It is Israel which has thrown Hamas a lifeline by sending increasing amounts of food and goods through the border crossings to alleviate the chronic shortages in Gaza. Reports of Hamas mulling a five-year truce with Israel in return for an easing of the blockade on the enclave have been circulating and appeared in regional media. Indications that Turkey, a staunch supporter of Hamas and Muslim Brotherhood has been acting as an intermediary, have not been denied by the Turks.

Some observers say, at least for now, Hamas is capable of putting down the threat from ISIS.

“I don’t think [ISIS or its affiliates] are a threat that Hamas cannot handle,” Schweitzer said. “Hamas is brutal enough and determined enough to meet that challenge.”