High-ranking Israeli officials and journalists alike have occasionally found themselves amazed at the waves of curses and vicious invective that Egyptian officials unleash when asked for their views on Hamas. In one recent encounter, a former IDF Southern Command chief had to calm one of his Egyptian counterparts, who was using particularly colorful language to express his views about high-ranking Hamas operatives in Gaza, replete with frequent allusions to their mothers.

The Egyptians have never troubled to hide their abhorrence of Hamas, particularly after President Abdel-Fattah el-Sissi took office in the summer of 2013. The Egyptian army has since blocked hundreds of tunnels that were dug between Gaza and Sinai and waged all-out war against the smuggling taking place from Egypt to Gaza.

But in the new Middle East, everything is possible. It seems that the current Egyptian leadership, the bitter enemy of the Muslim Brotherhood (which it ousted, and of which Hamas is a subsidiary), has decided to change its behavior toward Hamas. This decision stems not from any sudden affection on Egypt’s part for Hamas, but rather from Egypt’s hatred of the Islamic State terror group.

This change in direction, which is already visible on the ground, has Israel concerned. Suddenly the Egyptians are opening the Rafah Border Crossing, including for the entry of merchandise. This week, high-ranking Hamas operatives said that former Hamas prime minister Ismail Haniyeh, the incoming chief of its political wing, was planning a visit to Cairo in the near future — a dramatically symbolic step.

Head of the Hamas terror group, Ismail Haniya, waves to the crowd during an anti-Israel rally in the southern Gaza Strip city of Rafah on February 26, 2016. (Abed Rahim Khatib/Flash90)

Head of the Hamas terror group, Ismail Haniyeh, waves to the crowd during an anti-Israel rally in the southern Gaza Strip city of Rafah on February 26, 2016. (Abed Rahim Khatib/Flash90)

Haniyeh, who has lived outside Gaza for months, left Gaza with Egypt’s permission supposedly in order to perform the hajj, or pilgrimage to Mecca, one of the main duties incumbent on all Muslims. But a great deal of water has flowed through Wadi Gaza since then, and Haniyeh is still abroad, visiting Arab countries and non-Arab Muslim states. Osama Hamdan, Hamas’s official in charge of international relations, has had good reason to speak in media interviews about Hamas’s rapprochement not only with Egypt, but also with Iran.

Haniyeh, who won supporters abroad for his election as head of Hamas’s political wing, has also worked to strengthen Hamas’s relationship with various countries in the Muslim world.

Eased exits

Yahya Sinwar (screenshot)

Yahya Sinwar (screenshot)

The Egyptians allowed other high-ranking Hamas officials to leave Gaza along with Haniyeh. Among them was Rawhi Mushtaha, 57, a key Hamas operative who is considered one of the closest associates of Yahya Sinwar, Hamas’s strongman in Gaza.

Mushtaha, who was released from prison in Israel in 2011 as part of the Gilad Shalit prisoner exchange deal and is considered one of the officials who sets the tone in Hamas, has a great deal of influence over the military wing.

Mushtaha, it turns out, took advantage of the opportunity to leave Gaza not only for religious reasons, but also in order to spend time with his young wife, whom he married after 2011. (Photographs of him visiting one of the largest shopping centers in the United Arab Emirates have reached The Times of Israel.)

Rawhi Mushtaha and his wife in the UAE

Rawhi Mushtaha and his wife in the UAE

So what led to this shift in the relationship between Hamas and Cairo, this unprecedented reconciliation?

The change in direction began with Hamas’s decision to go to war against the Salafist groups in the Gaza Strip. From Hamas’s perspective, the Salafists, including those who identify with Islamic State, have become a real threat — mostly an ideological one, but also a physical one despite their relatively small number in Gaza. (There are roughly 700 to 800 Salafists in Gaza out of a population of approximately two million.) Intermittent rocket fire at Israel by the Salafist groups gave Hamas a major headache, to put it mildly, mainly due to the escalation in Israel’s response in recent months.

But the more significant threat is the internal one. As many as 40 members of Hamas have joined various Salafist groups in recent years, and some of them have crossed the border to join Islamic State’s affiliate Sinai Province. Commanders from Hamas’s military wing are also trickling into Sinai Province, including some who are considered experts in their fields, such as the use of anti-tank rockets and large explosive devices. To this we should add the murder of a Palestinian Shiite Muslim by Sunni extremists, as well as the wish to grow closer to Egypt.

Hamas began an operation two months ago in which approximately 200 Salafist operatives were arrested throughout the Gaza Strip — some for firing rockets at Israel, and others for engaging in religious-ideological activities that Hamas viewed as a challenge to its rule. While it is not known how many are still being held, the trend is obvious.

Egyptian army personnel supervise the destruction of tunnels between Egypt and the Gaza Strip at the border, near the town of Rafah, northern Sinai, Egypt, September 2013. (photo credit: AP/AP Television)

Egyptian army personnel supervise the destruction of tunnels between Egypt and the Gaza Strip at the border, near the town of Rafah, northern Sinai, Egypt, September 2013. (AP/AP Television)

Since the first ones to be arrested were Salafist operatives who had no connections to Islamic State’s Sinai Province, their arrests did not lead to friction with the neighbors across the border. But when Hamas recently arrested members of Liwa al-Tawheed, who are considered very close to Islamic State, a crisis suddenly erupted. One top Sinai Province operative called Hamas “infidels,” and Sinai Province commanders ordered smugglers in the Rafah sector to cease bringing any goods, principally materials used in Hamas’s military industry, from Sinai to Gaza.

While the number of tunnels in the Rafah sector was small to begin with, Islamic State has continued to provide Hamas in recent years with a large amount of dual-purpose materials such as steel cables, drills, pumps and electrodes — items that Israel would not allow into Gaza through the Kerem Shalom Crossing. But several weeks ago, Islamic State operatives contacted the smugglers individually, warning that anyone who allowed the entry of goods into Gaza would pay with his head. (Islamic State also stopped the entry of cigarettes into Gaza for religious reasons; Islamic extremists hold that smoking is forbidden.)

This act by Islamic State’s Sinai Province drew a punitive response from Hamas: a halt in the transfer of arms and ammunition from Gaza to Sinai. In addition, Mohammad Ramilat, one of the Sinai Province’s prominent members, who was in Gaza, was arrested two weeks ago in an effort to pressure Islamic State to continue the smuggling.

Ongoing cooperation

Despite the severe tension between the two groups, at least one aspect of cooperation is still going on, though to a lesser extent, even in moments of crisis: the bringing of wounded members of Islamic State to Gaza.

Islamic State has no medical center in Sinai where it can treat members who have been wounded in battle against the Egyptian army. Its only way out, medically speaking, is the Gaza Strip. And so, far beneath the radar, Hamas and Islamic State are keeping up coordination in this area, with the cooperation of well-known physicians in the Gaza Strip.

What, then, is pushing Egypt toward the thaw in its relationship with Hamas?

First, we should note that in recent months, we witnessed a true crisis in the relationship between Egypt and Palestinian Authority President Mahmoud Abbas. The recent elections for the Fatah leadership at the Seventh General Assembly, together with the exclusion of Mohammad Dahlan, Egypt’s ally, led Egypt to distance itself from Fatah as a whole, at least while Abbas is in charge.

Egyptian President Abdel-Fattah el-Sissi, left, greets Palestinian Authority President Mahmoud Abbas during his inauguration ceremony at the presidential palace in Cairo, Egypt, on June 8, 2014. (AP/MENA)

Egyptian President Abdel-Fattah el-Sissi, left, greets Palestinian Authority President Mahmoud Abbas during his inauguration ceremony at the presidential palace in Cairo, Egypt, on June 8, 2014. (AP/MENA)

It was at this point that the first steps toward reconciliation began to be evident, mainly regarding the opening of the Rafah Border Crossing. Still, it became clear recently that this was about far more than an attempt to damage Abbas’s status. It seems that the Egyptians realized that the situation in Gaza was not going to change anytime soon and that they had to deal with it as it was.

In other words, Egypt would like to see Hamas fighting against Islamic State’s Sinai Province instead of helping it, working to stop the terror attacks against Egyptian troops in Sinai — attacks that rely on support from the Gaza Strip — and stopping the propaganda against President Sissi that can be seen all over Gaza.

In order to do this, Egypt must try to normalize its relations with Hamas. This normalization will involve Egypt’s opening of the Rafah Border Crossing more regularly, granting departure and entry permits to high-ranking Hamas operatives and ordinary residents, and assisting Hamas’s civilian projects. This is why Egypt allowed the entry of construction materials, such as concrete, through the Rafah border crossing. (To no one’s surprise, Hamas’s military wing uses concrete to build tunnels against Israel.)

New cars and motorcycles from Egypt were brought into the Gaza Strip along with the concrete. This is the direction in which Egypt plans to move forward with Hamas: official normalization of relations, with Egypt supervising the security aspect.

Cairo officials are at least partly aware of the advantages and disadvantages of this move. There can be no doubt that opening the Rafah Border Crossing regularly, for example, will strengthen Hamas at Abbas’s expense and make its rule of Gaza more legitimate. On the other hand, if Hamas should take tougher measures against Islamic State, that could lead to a marked reduction in terror attacks in the Sinai Peninsula by Sinai Province.

Hamas officials realize that if Egypt allows high-ranking members such as Haniyeh and Mushtaha freedom of movement, Hamas’s international standing will grow stronger. Perhaps most important of all in the balance of power within Hamas, the leadership in Gaza will be able to take back control from the leadership abroad. And perhaps, just perhaps, Haniyeh, Sinwar and Mushtaha will be the true leaders of Hamas at the expense of Khaled Mashaal and his comrades in Qatar and Turkey.