CAIRO/GAZA (Reuters) - After years of strained relations, Egypt is moving closer to Hamas in Gaza, offering concessions on trade and free movement in return for moves to secure the border against Islamic State fighters who have killed hundreds of policemen and soldiers in northern Sinai.
Egypt has been at odds with Hamas, which controls the Gaza Strip, since a crackdown by Cairo on the armed group's Islamist allies. Egypt closed the border, opening it only rarely.
But in recent weeks Egypt has eased restrictions, allowing in trucks laden with food and other supplies, and providing relief from an Israeli blockade that has restricted the flow of goods into the coastal territory.
The relaxation follows high-level Hamas visits to Cairo, which wants to restore its role as a regional powerbroker and crush Islamic State followers in the Sinai Peninsula, a strategic area bordering Gaza, Israel and the Suez Canal.
It builds on what Egyptian and Palestinian sources say are efforts by Hamas to prevent the movement of militants in and out of Sinai, where they have killed hundreds of Egyptian soldiers and police since general-turned-president Abdel Fattah al-Sisi overthrew the Muslim Brotherhood in 2013.
Egyptian and Palestinian officials say the changes could signal a new era of closer cooperation after years of tension.
"We want cooperation in controlling the borders and tunnels, the handover of perpetrators of armed attacks and a boycott of the Muslim Brotherhood. They want the crossing to be opened and more trade," one senior Egyptian security source said.
"This has actually begun, but in a partial way. We hope it will continue."
While it doesn't engage directly with Hamas, Israel is working with Egypt on border security and monitoring of Gaza. Military officials have voiced support for any steps that bring greater stability to northern Sinai and Gaza.
Hamas has increased security along its side of the border with Sinai over the past year, deploying hundreds of security forces and erecting more watchtowers. The group has also moved to round up Salafi Jihadists, who oppose an Egyptian-brokered 2014 ceasefire with Israel.
Hamas, whose charter calls for Israel's destruction but which has no ambitions for global jihad, has not said how many militants it has captured and refuses to call them jihadists.
Egypt has given Hamas a list of about 85 fugitives, who it says are implicated in attacks and wants extradited, the Egyptian security source said. Hamas denied links with some of them and sources in the group said extraditions were unlikely though it might make its own inquiries.
Hamas has however let Egypt know that it has no interest in stoking unrest in an Arab neighbour that has mediated several truces with Israel and among rival Palestinian factions.
"If we compare it with a year ago, the situation or the relationship is better but it is not yet what is needed," Mahmoud al-Zahar, a senior Hamas official, told Reuters.
"The needs of our people are great, their need to travel, pursue education or treatment, attend to their businesses and families abroad, and also the need for open trade with Egypt."
The blossoming ties have been advanced by intense diplomacy, culminating last month in a visit by Ismail Haniyah, a deputy leader of Hamas, to meet Egyptian intelligence officials.
A series of conferences on Palestinian affairs have also taken place in Egypt in recent months attended by figures from Palestinian factions.
Organisers said the conferences were part of efforts to restore Egypt's regional role following the chaos of the 2011 Arab Spring revolts.
"The situation now is returning to normal," said Elazb al-Tayeb Taher, writer on Arab affairs at the state-owned Al-Ahram newspaper, which hosted one of the conferences in November.
"Egyptian intelligence is restoring its relationship with Hamas in accordance with certain guidelines, chief amongst them being that Hamas does not become a major gateway for threats from Gaza targeting Egypt's national security."
Despite mutual distrust, Hamas and Egypt kept communication channels open, with Hamas officials regularly invited to Egypt.
But ties hit a low in 2013, after Sisi overthrew President Mohamed Mursi, banned the Muslim Brotherhood as a terrorist organisation and jailed many of its supporters.
Ansar Bayt al-Maqdis, a militant group that emerged in North Sinai in the chaos of 2011 and initially attacked Egypt's gas pipelines to Israel, turned its guns on Egyptian forces. In 2014, it joined Islamic State and has since attacked in Cairo, killing 28 people in a church in December.
Blockaded by Israel and facing the closure of their only other outlet, Gazans dug thousands of tunnels to smuggle in building materials and consumer goods and, according to Egyptian officials, smuggle out arms and fighters.
In a bid to crush the militants, Egypt's military razed hundreds of homes and destroyed at least 2,000 tunnels.
Curfews, checkpoints and air strikes have devastated an area that once drew holidaymakers to its Mediterranean shore.
The desire to secure the area and restore a semblance of normality is as strong for Egypt, which wants to lure back foreign investors who fled after 2011, as it is for Gazans.
Egyptians who organised the Palestinian conferences suggested the border might be reopened to trade for 10 or 15 days at a time - rather than a few days every six weeks at present - to build trust.
But the ultimate aim is more ambitious; a free trade area and an industrial zone on the Egyptian side to facilitate commerce, allow Gazans to travel abroad, and create jobs for those who might otherwise join the militants.
"We've gotten to a point now with Hamas where we're working on a framework on which to build for the coming period, and this will be contingent upon controlling the borders and the crossing will be open routinely," said Tareq Fahmy, of the state-linked National Center for Middle East Studies, which co-organised two Palestinian conferences last year.
"We're thinking of direct trade and all this is pivotal for our brothers in Hamas and the Gaza Strip, but ... trust-building processes don't take place overnight."
For residents of northern Sinai, who face a gamut of checkpoints each day, open trade seems an outlandish notion. The conflict has rendered the area a wasteland of demolished houses, sand berms and trenches.
"It's early to talk of trade. We are still living in a security zone," said one resident.
Additional reporting by Ahmed Mohamed Hassan in Cairo; editing by Giles Elgood