Hamas fears rocket-fire by Salafist rebels could trigger retaliatory action by Israel in Gaza. Pictured is a Palestinian man surveying damage after an Israeli airstrike, May 27, 2015. Reuters/Mohammed Salem

Terrorists claiming loyalty to the Islamic State group took responsibility for the assassination of a Hamas commander in Gaza Sunday. The Army of the Islamic State said it placed a bomb in a vehicle belonging to Saber Siam and detonated it, broadcaster Arutz Sheva reported.

There is no love lost between the two militant organizations. The Islamic State group, also known as ISIS, considers Hamas "heretical," accusing the group of conducting a war on religion. ISIS has warned Hamas to “end its war against religion in Gaza” or “face the consequences,” Arutz Sheva said.

Residents of Gaza have been warned to stay away from government offices. Arutz Sheva, however, said it was unable to verify whether the Army of the Islamic State actually is an ISIS affiliate, but Israeli sources told the broadcaster a group of Salafist rebels is trying to take over Gaza.

Earlier this month, a group calling itself Supporters of Islamic State of Iraq and Syria in Jerusalem conducted a mortar attack on Khan Yunis, targeting Izzadin Kassam, a base occupied by Hamas' armed wing, Agence Frence-Presse reported. The attack may have been retaliation for a Hamas attack on a mosque in Deir el-Balah favored by ISIS supporters, but which Hamas said is frequented by radicals plotting against the government.

Hamas has arrested dozens of Islamic State group supporters in recent weeks, including imams, following the ISIS takeover of the Yarmouk Palestinian refugee camp near Damascus in a massive crackdown on what Hamas describes as extremist elements. Hamas swore to avenge the execution of a senior Hamas official inside the camp.

Haaretz reported Hamas doesn't see the ISIS supporters as a real threat, believing they lack the logistical and financial wherewithal to oust Hamas. Nevertheless, Hamas' security services were reported on high alert.

The escalating battle between ISIS and Hamas has led to a development unthinkable just a few months ago: Hamas and Israel are working toward the same goal. 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.

“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 released after the destruction of the mosque.