How seething Egypt surprised the world and sealed the deal
Demonstrators protesting last month in Tahrir Square - where the revolution began - against the military government's retention of emergency laws
On October 9, in the most violent demonstrations in Egypt since the revolution, the Christian Coptic minority took to the streets to protest.
Twenty-four civilians and soldiers were killed on that day. But throughout the rioting and the bloody reprisals by the military, Major General Murad Muwafi, director of Egypt's feared Mukhabarat intelligence service remained closeted away.
He was busy dealing separately with two delegations, one Israeli and one Palestinian, and putting the final touches to the prisoner swap.
Ever since President Hosni Mubarak was forced from office eight months ago, Israel's ties with Egypt have appeared to deteriorate in a one-way, downward spiral. Last month, when Egyptian civilians stormed Israel's embassy in Cairo, trapping six security guards inside, Defence Minister Ehud Barak could not reach his counterpart, Field Marshal Mohamed Tantawi, on the phone. Only American intervention saved the Israeli guards.
And yet it was this temporary, weak and overtly hostile administration that brokered the very deal that had eluded the Mubarak regime for four and a half years.
Egypt's sponsorship of the indirect talks and the efforts its military leadership put into cajoling both sides to close the deal underlines a fact that the country's leaders prefer not to acknowledge openly, but know well.
The endurance of the treaty with Israel is a key factor in maintaining Egypt's relationship with the US and other Western powers. And with Turkey, Saudi Arabia and Iran all challenging its regional hegemony, a low-key but stable strategic alliance with the Israelis is an asset.
The military caretaker government proved not only to Israel that it could deliver the goods, but also to Hamas. They distrust the Palestinian Islamist movement but, with Gaza on their border and Hamas looking to relocate its Damascus headquarters, Cairo prefers to keep Hamas close by, where they can control them and try to dislodge them from Tehran's orbit.
Israel for now is choosing to turn a blind-eye to these developments, preferring instead to praise Egypt's involvement in the negotiations at every opportunity.
It is no coincidence that last Tuesday, minutes before the deal with Hamas was officially announced, Mr Barak's office issued an official apology over the deaths of five Egyptians killed in crossfire during the August 18 attack on Israel. Meanwhile, Egypt signalled it could release Ilan Grapel, the American-Israeli law student whom Cairo suspects of being a spy for Israel. Both sides are trying hard to prove that they can work together.