On Thursday, during the early hours of the ceasefire, the Hamas political chief in Gaza Ismail Haniyeh thanked Iran “especially” for its assistance in the battle with Israel. The IDF, throughout the eight days of Operation Pillar of Defense, embedded the following line in each of its emails: “The Gaza Strip has been turned into a front line base for Iran, forcing Israeli citizens to live under unbearable circumstances.”

Yet the Hamas-Iran link, ever since the eruption of violence in Syria almost two years ago, has actually been under considerable strain. And, according to several experts, it was precisely the issue of Iran and the mutual concern over the growing strength of its proxy in Gaza – Palestinian Islamic Jihad – that allowed Israel, Egypt and Hamas to reach a ceasefire agreement.

“Iran is using Islamic Jihad to try and take over Gaza,” said Eitan Meyr, a former assistant to the Advisor for Counter-Terrorism in the Prime Minister’s Office and a fellow at the Institute for Counter-Terrorism in Herzliya. “Hamas is more afraid of them than of us.”

Meyr argued that Israel and Egypt, and to a certain extent Hamas, share a common interest in denying Iran a sizable foothold in Gaza. “We are not friends but we do have a mutual interest – denying the presence of an Iranian proxy on our [southern] doorstep.”

In some ways, Islamic Jihad, operating under Iran, is reminiscent of Hamas under the Palestinian Authority. Soon after the signing of the Oslo Accords in 1993, Ibrahim Makadmeh, a senior Hamas figure, argued in two separate books that attacking the PA with force would bring ruin on Hamas; attacking Israel, however, violating the Oslo Accords and in that way baiting Israel into attacking the PA, would weaken the PA and deliver the seat of government to Hamas like low-hanging fruit, Shlomi Eldar reported in “Getting to Know Hamas.”

Currently, Hamas is still very capable of reining in Islamic Jihad. But a full-fledged Israeli invasion of Gaza would have weakened the organization, loosened its grip on power and ushered in an era of at best reduced governmental control, in which terror groups like Islamic Jihad thrive.

For years the cooperation between the Sunni Hamas organization and the Shiite-led Islamic Republic of Iran adhered to the adage of me and my cousin against the stranger; me and my brother against my cousin. In other words, despite religious and cultural differences – a nearly 1,400-year-old Sunni-Shiite feud that has always been dominated by the Sunni majority – the shared desire to eliminate the state of Israel was sufficient grounds for cooperation.

Palestinian Hamas leader Ismail Haniyah meeting with Kuwait's Emir Sheikh Sabah al-Ahmad al-Sabah (Photo credit: Mohammed Al-Ostaz/ Flash 90)

Palestinian Hamas leader Ismail Haniyah meeting with Kuwait’s Emir Sheikh Sabah al-Ahmad al-Sabah (Photo credit: Mohammed Al-Ostaz/ Flash 90)

This formula has been jostled by the turbulence of the Arab Spring. The rise of Islamist regimes, such as the one in Egypt, has translated into a greater shared hostility for Israel on the one hand, but an increase in the importance of religion and ethnicity in the region alongside a dwindling emphasis on national interests, as seen in Iraq, Lebanon and especially Syria.

The battle there, which began in March 2011 and has pitted mostly Sunni Syrians against the Allawite, pro-Iran regime of Bashar Assad, has dealt the Hamas-Iran alliance its most serious blow. In January, the political chief of Hamas, Khaled Mashaal, ended his 11-year sojourn in Damascus, closing the organization’s headquarters there and relocating to the resolutely anti-Iran and US-friendly desert kingdom of Qatar, which is said to be bankrolling the uprising against Assad. “Their flight from Syria made Iran very, very angry,” said Bassem Eid, a Palestinian human rights activist and commentator on Middle East affairs. “For Iran, it was nothing less a coup.”

Over the past three months, he said, the regime in Syria has been steadily bombing the Palestinian al-Yarmouk refugee camp outside Damascus and anti-Syria demonstrations in Gaza have become more common.

“Hamas and Iran are not friends,” said Arie “Leybo” Livne, the former commander of the southern sector for the Shin Bet internal security service and a research fellow at the ICT Herzliya.

Speaking of the alliance between the parties, he said, “Once you take Damascus out of the Iran-Syria-Hamas axis, there is no more axis.”

The Assad regime was furious with Mashaal and Hamas for leaving Damascus, accusing the Hamas chief of having sold out “resistance for power.”

In October, in perhaps the most concrete sign of Hamas’s allegiances in the battle for supremacy raging through the region, the Emir of Qatar, Sheik Hamad bin Khalifa al-Thani, a stark opponent of Iran’s, became the first head of state to visit Hamas-ruled Gaza, breaking five years of diplomatic isolation and pledging some $400 million in aid.

This signaled a palpable shift in Hamas’ alliance with Iran, which will, talking points aside, surely be tested during the coming year – as Iran’s bid for a nuclear weapon comes to a head.

The United States and its European partners will require, at the very least, robust behind the scenes backing from the Sunni states, including Egypt and the oil-rich nations of Saudi Arabia and Qatar.

In this Hamas is trapped between its two clashing identities. On the one hand, according to an Israel Radio interview with Kadima MK and former deputy director of the Shin Bet Israel Hasson, Hamas views itself, after shirking the rule of the Palestinian Authority in Gaza, as the bellwether of the Arab Spring — the first Arab entity to shake off corrupt, semi-secular control for a devout, Islamist government in the mold of Turkey and Egypt. In other words, a legitimate mainstream Sunni regime.

On the other hand, according to Livne, Hamas’s credibility within Gaza is also very much linked to its ability to retain supremacy as the chief agent of “resistance” to Israel.

Livne described the two major players in the region as Egypt and Iran, both vying for supremacy in the Middle East. “In the end, the war for control of the region is between them,” he said. And Hamas – linked by ideology and religion to the Muslim Brotherhood of Egypt – “does not want to be the marionette of Iran.”