The scene earlier this month in the Gaza Strip was unusual to say the least: Hamas, the hardcore Sunni Muslim group ruling the Gaza Strip, was bulldozing a Sunni mosque in the heart of Gaza. The mosque was believed to be a base for fighters belonging to a new group called Supporters of the Islamic State in Jerusalem, an affiliate of ISIS, which Hamas sees as a rival and a dangerous influence in the region. That fear has led to a development unthinkable just a few months ago: Hamas and Israel are working toward the same goal.

Almost a year since Hamas and Israel faced off in Gaza last summer, the two now face a common enemy -- the Gaza-based militants who have rebranded under the black and white flag of the ISIS. The rise of those extremists in Gaza is now threatening neighboring countries like Israel and Egypt, and giving Hamas, officially the enemy of Egypt and the sworn foe of Israel, leverage as the one entity that can stop ISIS from building a dangerous foothold between the two countries.

During the mosque raid, Hamas also arrested several members of Ansar Bayt al-Maqdis, an Egyptian militant group that last year became ISIS' first branch outside of Iraq and Syria, underscoring how the threat of a rising ISIS in Gaza is directed toward Egypt, not just Israel.

“In the light of Hamas’ new crackdown, we renew our loyalty to [ISIS Caliph Abu Bakr] al-Baghdadi and call on him to strengthen his influence and to launch a campaign in Palestine,” said a statement from Supporters of the Islamic State in Jerusalem released after the destruction of the mosque.

And according to the Israeli military, there is only one way to fight that threat short of sending the army into Gaza again. Israel should let Hamas do the job.

“Gaza has an independent authority that functions like a country,” the head of Israel’s Southern Command, Maj. Gen. Sami Turgeman, reportedly said during a meeting with Israeli officials last week. “Within the country there is a ruler that is called Hamas. … The only replacement for Hamas is the IDF [Israel Defense Forces] and authoritarian chaos. Other than Hamas, there is no other axis that could control [Gaza].”

But the threat in Gaza is still nowhere near as dangerous as the core ISIS based in Syria and Iraq.

Gaza’s proximity to the lawless Sinai desert and the abundance of weapons available in the strip has made it home to a number of different extremist groups. For years, it has housed militants who want to unseat Hamas from power, attack Israel and declare their own Islamic state. But those militants haven’t formed a unified group yet that could threaten the status quo.

There is no Islamic State in the Gaza Strip,” Husam Badran, a Hamas spokesperson based in Qatar, told International Business Times. “There are scattered members who sympathize with some ideas and adopt some of their policies, but they do not make up a collective organization on the ground.”

“Hamas knows the Salafis, it knows where they are and who they are,” said Maha, a Gaza resident whose name has been changed for security reasons, referring to the followers of a particularly strict interpretation of Sunni Islam. “Hamas has the power in Gaza,” she said.

For now, the Supporters of the Islamic State in Jerusalem’s ties to ISIS are only aspirational; the group is merely a new incarnation of a previous entity, called the Mujahedeen Shura Council in the Environs of Jerusalem. The U.S. State Department, which declared it a terrorist organization last August, described it as “an umbrella group composed of several jihadist terrorist subgroups based in Gaza that has claimed responsibility for numerous attacks on Israel since the group’s founding in 2012.”

When the Egyptian government began a major crackdown on Sinai militants last year, many leaders from Ansar Bayt al Maqdis took refuge in Gaza, which they reached using underground smuggling tunnels. Hamas’ policy was to allow them to silently exist as long as they would not cause trouble with Israel or challenge Hamas rule over the Strip.

That policy of looking the other way ended when Hamas and Israel entered a truce to end the summer war, which some extremists in Gaza saw as a weakening of Hamas’ position toward Israel and Egypt, and took as their cue to begin attacks against Egyptian and Israeli targets, as well as on Hamas bases. That led Hamas to take action, which thrust the group into the unlikely role of a moderate influence.

“Hamas brigades actually stopped Salafi groups from firing rockets at Israel,” said Zack Gold, a visiting fellow at the Institute for National Security Studies in Tel Aviv. “So not only are they no longer interested in jihad, but they’re actively stopping jihad.”

Some political factions within Gaza say Hamas has used the uptick in attacks as an opportunity to gain additional legitimacy, while quelling internal threats and solidifying its position within the Gaza Strip, where it had been accused of running an incompetent government and doing nothing to end the Israeli blockade.  

“Hamas wants to get out of distress that occurred because of the war, the siege and non-payment of staff salaries, and is not interested in a new nuisance,” said Tholfikar Swairjo, a spokesman for the Popular Front for the Liberation of Palestine, a secular Marxist political party in Gaza that is a Hamas rival and also has its own armed wing.  

“We offered them to help them control ... Islamist extremists by giving them information and also fighters if they want it, but they refused because they are afraid of the internal revolution,” Swairjo added.

Israel and Hamas may not be cooperating outright in the face of the increased Salafi threat, but they are not impeding each other’s operations either, experts said. What’s more, Israel has very good intelligence-gathering operations in the Gaza area. In 2012, an Israeli airstrike killed Hisham al-Saidini, leader of al-Tawhid al-Jihad, a Salafi extremist group active in Sinai and Gaza, shortly after he was released from a Hamas-run prison.

“A worry that they share is that these Salafi jihadi groups will goad the two sides into war,” Gold said. If militant groups were able to attack Israel and prompt a retaliation, “we could see an escalation into a war that neither Israel nor Hamas wants,” he added.

But for the time being, the local ISIS aspirants in Gaza do not have the critical mass and cohesion to be a part of the so-called caliphate.  

“The Islamic State basically ignored them,” Gold said. “The understanding was there were so many disparate groups that have no real influence and no real power, so why recognize their existence in a way that would be an embarrassment to the Islamic State in Syria and Iraq?”

However, the militants’ ties to Sinai, and Hamas’ increased crackdowns, could push the Strip’s Salafi factions together.

“There is no strong indication of ISIS leadership in Iraq and Syria to coordinate with Gaza, but [the militants] can use the ISIS name and global authority to convince disparate groups to come together,” said Harleen Gambhir, a counterterrorism expert at the Institute for the Study of War. “ISIS explicitly imposed a strategy of getting governments to crack down to convince populations to join.”

But so far, Gazans are more concerned with the dire poverty they live in than with the possible rise of a new extremist group.

“People in Gaza have more important issues, people don’t care. People want to have food,” Maha said, adding that civilians aren’t concerned with a possible ISIS insurgency, because “Hamas is controlling Gaza with an iron fist. No one can mess with Hamas now.”