A series of meetings between Hamas and senior officials in Cairo in recent weeks points to improving ties between Egypt and the Islamist Palestinian movement, with implications for Gaza, Palestinian politics and the wider region.
For much of the last decade, Egypt has joined Israel in enforcing a land, sea and air blockade of the Gaza Strip, a move to punish Hamas and its armed wing, which seized the territory in 2007 and has controlled it since.
The situation has worsened in the past month as Israel, at the request of the West Bank-based Palestinian Authority (PA), has cut electricity to Gaza, leaving it with barely four hours of power a day.
The sanctions are part of a yearslong effort by the PA, led by the rival Fatah party, to force Hamas to relinquish power in Gaza and join a unified government.
Power cuts have hit hospitals and water treatment plants, squeezing Gaza's two million people amid a draining heat wave.
Sensing the need to act, and worried about losing popular support, Hamas has sought to mend ties with Egypt, which controls their one border crossing and has, under President Abdel Fattah el-Sissi, been highly wary of ties between Hamas and the Muslim Brotherhood, which Sissi ousted from power after mass protests.
Hamas's newly appointed leader in Gaza, Yahya Sinwar, whose background is with the group's militant wing, met Egyptian officials, including the intelligence chief, last month.
The meetings in Cairo were believed to have been facilitated by Mohammed Dahlan, 55, a former senior Fatah official who is originally from Gaza and is now a staunch opponent of Palestinian Authority President Mahmoud Abbas, Fatah's leader.
Potential challenge to Abbas
Dahlan, who spends much of his time in the United Arab Emirates and is close to Egypt, has emerged as a powerbroker in the region, determined to bridge differences between Hamas and Cairo and potentially challenge Abbas for leadership.
In that respect, closer ties between Hamas and Cairo are a serious threat to Abbas, regional analysts said.
Not only because they help to bolster Hamas's credibility in the region, but because they empower Dahlan and undermine the ability of the Palestinian Authority to cast itself as the dominant political body for Palestinians, they said.
Israel, which signed a 1979 peace treaty with Egypt and coordinates closely with it on security, is maintaining a wary eye on discussions between Egypt and Hamas. Like the United States and the European Union, it regards Hamas as a terrorist group and wants to keep its influence contained.
After the last round of meetings in Cairo, Hamas cleared land on its side of the border, creating a buffer zone with watchtowers, cameras and barbed-wire fences in a concession to security-conscious Egypt.
"These measures serve as a message of assurance to the Egyptian side," Tawfiq Abu Naeem, the Hamas-appointed head of security services in Gaza, told reporters.
Since then, Hamas officials have returned to Cairo for more talks. Sources say Hamas wants Egypt to open its Rafah crossing for longer and to increase energy supplies and imports.
Egypt wants information on "radical elements" entering and leaving Gaza and help with tracking Islamic State-affiliated militants attacking Egyptian forces in northern Sinai.
Egyptian officials did not immediately respond to requests for comment on the discussions. An Israeli foreign ministry official declined to comment.
In a sign that the talks are rattling Palestinian politics, Abbas, 82, will visit Egyptian President Sissi this week.
And later Wednesday, Hamas's top leader, Ismail Haniyeh, will deliver one of his first public speeches since his election in May. Political observers expect him to address Hamas' improved ties with Egypt as well as the ever-present tensions with Israel and the Palestinian Authority.
"I believe relations between Egypt and Hamas have taken a big move," said Akram Attallah, an independent analyst in Gaza. "For the first time, we can say there is joint action between the two sides, a joint cooperation. That has never been official since the Hamas movement was founded 30 years ago."
Attallah sees Dahlan's mediation as critical. As Abbas has grown more frustrated with Hamas and tried to increase pressure on the group, it has strengthened Dahlan's role as a broker.
Abbas expelled Dahlan from Fatah in 2012 and Dahlan has been in self-imposed exile since. The last thing Abbas wants is for him to return to Gaza, with Egypt's approval, as a hero.
"Dahlan employed this moment to present himself as the most efficient party in the Palestinian arena and a savior for Hamas," said Attallah, suggesting each side had gained: Dahlan in terms of leverage and Hamas as a political partner.
Regional analysts are closely watching what closer ties with Egypt may mean for Hamas' relations with Qatar, which in recent years has spent more than $500 million improving infrastructure and building clinics in Gaza.
Egypt and Saudi Arabia are now leading a Sunni-Arab drive against Qatar over its ties with Iran, accusing it of fomenting terrorism, a charge Doha denies. The analysts say if Egypt is forging better relations with Hamas, it may well insist on Hamas giving up its friendship with the emirate.