What has been the nature of relations between Hamas and Salafi jihadi groups? The question is worth examining because Hamas is sometimes equated with the latter ideologically while on other occasions a strict dichotomy of enmity and opposition is painted between Hamas and the Salafi jihadi groups.
In fact, some nuances emerge depending on location. Within the Gaza Strip itself that is ruled by Hamas, some small Salafi jihadi groups can be found. In this case, there is no doubt that these groups are at odds with Hamas, which has arrested members of these groups and cracked down on them multiple times.
The Salafi jihadi groups in Gaza raise multiple objections against Hamas. For example, as Jaysh al-Islam told me in the first media interview that the group has done in many years, Hamas is an apostate movement because it rules by 'man-made' laws. This criticism reflects a common attack levelled by Salafi jihadis at Hamas and the wider Muslim Brotherhood movement out of which Hamas has emerged: namely, that they have compromised on ruling in the totality by God's law.
Another problem for the Gazan Salafi jihadis concerns Hamas' ties with Iran. For instance, Abu Hafs al-Maqdisi, the amir of another Gazan Salafi jihadi faction called Jaysh al-Ummah, shared a fatwa on his Telegram channel that inquired about Hamas' acquisition of arms from Iran. The response was that the problem is not that Hamas takes arms from Iran per se, but rather that is 'allied with the ruling regime in Iran that permits fighting the peoples of the Ummah alongside the Russian Crusader campaign in Syria, and the American Crusader campaign in Iraq, and this campaign has killed and displaced in cooperation with Iran's sectarian militias millions of the Muslims.' The fatwa goes on to complain that Hamas has not only failed to defend Muslims against this campaign but has also tried to rehabilitate Iran's image before Arab and Muslim public opinion.
The final major criticism of the Gazan Salafi jihadis is their perception of Hamas' approach to Israel. For instance, in an article in May 2018, Abu Hafs al-Maqdisi asserted that Egypt and Qatar have played a role in 'taming' Hamas to become a carbon copy of Fatah, with revision of the founding charter, accepting a state along 1967 borders and the possibility of direct negotiations with Israel. In Maqdisi's view, 'liberation' of Palestine will not come through negotiations but rather through 'returning to God', dissolving the authority created by the Oslo Accords, armed jihad, implementing God's law and making the Palestinian issue a cause of the Ummah.
Outside of the Gaza Strip, a more interesting picture emerges, in particular regarding the Islamic State's Sinai affiliate (Wilayat Sinai) that overwhelmingly dominates the insurgency in that region against the Egyptian armed forces.
Some controversy has emerged over whether there have been ties between Hamas and Wilayat Sinai. Documents leaked as part of internal Islamic State ideological disputes do confirm that- at least at one point- there was correspondence between Hamas and members of Wilayat Sinai.
The documents are a short treatise written by an Islamic State 'extremist' called Abu Maram al-Jaza'iri, who eventually fled from the organization. Abu Maram notes that he reviewed the file of correspondences between Hamas and 'some of the [Islamic State] brothers in Sinai' (specifically, Hamas' military wing and someone 'entrusted by the brothers in Sinai' to contact the Hamas side). Abu Maram states that the issue at hand is whether Muslims can seek the aid of apostates (in this case, Hamas), such as through coordination in weapons movement, seeking material aid and transfer of wounded.
While Abu Maram accepts that there are certain circumstances that can permit seeking the aid of apostates, he condemns the correspondence on the grounds that the one entrusted to contact Hamas does not declare Hamas to be apostates, but rather pursues correspondence on friendly and conciliatory terms. In addition, he argues that Wilayat Sinai has no need for cooperation with Hamas, but rather the latter is in need of the former.
To be sure, there are limitations here. We do not know the extent of weapon transfers and other mutual assistance that might have occurred as we do not have access to the actual text of the correspondences. Another problem is that no date is attached to Abu Maram's commentary, nor does his commentary delve into chronology.
Nonetheless, there are plausible, pragmatic explanations for why there was correspondence with discussion of issues of cooperation and support. One should also note that Sinai is fundamentally a continuation of a pre-existing insurgent group: Ansar Bayt al-Maqdis, which did not openly declare Hamas to be an apostate movement. In the end though, as MEMRI argues, it is probably correct that relations deteriorated by late 2016, such that Wilayat Sinai has openly declared Hamas to be apostates since that time.
In short, Hamas' own relationship with Salafi jihadis as a whole is on very negative terms- something clearly borne out in the Gaza Strip. This rift exists on account of Hamas' approach to governance as well as the group's approach to Iran and Israel. However, for pragmatic and not ideological reasons, Hamas' military wing corresponded with the Islamic State's Sinai affiliate and likely cooperated with it.