The main breakthrough came in July. After five years of negotiations, Hamas forwarded a letter to Israel in which, for the first time, it outlined its final terms for a prisoner swap for Gilad Schalit.Three months earlier, David Meidan, a former senior Mossad operative, had been appointed chief mediator to the Schalit talks by Prime Minister Binyamin Netanyahu. Upon receiving the letter, he immediately got to work.RELATED:Gilad Schalit expected back in Israel on Tuesday Timeline of the proposed prisoner exchange The first indication that Hamas was willing to ease up its demands came fairly quickly. After studying the letter and seeing the names of Tanzim chief Marwan Barghouti, PFLP chief Ahmed Sadat and some top Hamas terrorists, Meidan immediately made clear that these people – the so-called “symbols” of Palestinian terror – would not be released. Surprisingly, Hamas did not say no.The same week that the letter was sent by Hamas, the Egyptian mediator – a deputy of Intelligence Minister Murad Muwafi – renewed his activity. In Israel, Cairo’s renewed interest in the Schalit issue was understood as a result of a number of elements.First, the interim military-run government in Egypt wanted to show the world that while the country appears to be in disarray and on the verge of governmental collapse, this is not the case. Instead, by mediating the Schalit deal, Egypt was able to show that it still is a player with major regional influence.The second reason is more internal and has to do with Egypt’s concern with Hamas, but even more so with its founding father – the Muslim Brotherhood. The Brotherhood is expected to gain significant political power in the upcoming elections. By striking a deal with Hamas, Egypt gains some political influence over what happens in the Gaza Strip.Getting back to July, after receiving Hamas’s response, the Egyptians proceeded to hold six rounds of talks between Meidan and Izhard Awadallah, the head of the Hamas delegation to the talks. Ahmed Jabari, Hamas’s military commander, was also a frequent participant.The talks were usually held in Cairo at the Intelligence Ministry. Meidan and the Israeli delegation would sit in one building and Awadallah and the Hamas delegation in another. The Egyptians would move back and forth with messages and instructions.The last round of talks began at 9 a.m. Monday and continued for 24-hours straight until 9 a.m. Tuesday, when Meidan signed the deal. Meidan was joined at the final round of talks by Shin Bet (Israel Security Agency) chief Yoram Cohen and Netanyahu’s military secretary Maj.-Gen. Yohanan Locker.Contrary to some reports, while Germany played a role in the negotiations, it was at a much earlier stage. The German mediator had crafted an agreement – which one Israeli official called a masterpiece – already two years ago. Hamas, however, balked at it since it felt that the Germans were biased toward Israel.Hamas had a number of reasons for finally agreeing to a deal.The first is that while Israel has paid a price for not releasing Schalit, so has Hamas, which as proven by the deal, was holding a bargaining chip for five years that is worth 1,000 convicted terrorists.The second reason has to do with the instability in Syria and Hamas’s fears that it is losing its headquarters in Damascus. Musa Abu Marzook, Khaled Mashaal’s deputy, has already established an office in Cairo that could potentially replace the one in Damascus. In addition, there are claims that the Egyptians have promised an increase in trade with Gaza. Hamas has also been hit hard by Palestinian Authority President Mahmoud Abbas’s move at the United Nations last month that gave him and his Fatah party a major boost among the Palestinian public. By securing the release of 1,000 prisoners, Hamas is gaining political points.One of the main sticking points throughout the negotiations was Hamas’s concern that the swap would be perceived as a “deportation deal” if a majority of the released terrorists were deported from the West Bank and Gaza. The change in that position came in March, when Cohen was appointed head of the Shin Bet.Yuval Diskin, Cohen’s predecessor, had rejected the possibility that a significant number of terrorists would be allowed to return to the West Bank. To Gaza, he agreed to a slightly larger number.Cohen immediately immersed himself in the negotiations and established a rapport with Meidan. Cohen decided to be a little more daring than Diskin and agreed to increase the number of prisoners who would be allowed to return to the West Bank and Gaza. By doing this, and claiming that the results would be “containable,” Cohen provided Netanyahu with the security backing he needed to be able to move forward with the negotiations.The July talks did not start from scratch. Instead, they picked up from where Israel and Hamas had left off two years ago and were based heavily on the previously nixed German proposal. The two stages of 450 and 550 releasees were agreed upon in 2009. Now, the sides had to work through the names.Meidan, working on instructions from Netanyahu, made two points clear from the beginning – First, Israel would not release “symbols,” and second, it was willing to allow some of the released prisoners to go to the West Bank, and even more to Gaza.Israel also, for the first time, agreed to release prisoners from east Jerusalem, as well as Israeli Arabs. These two categories had never before been seriously considered for release and were nixed during the talks led by the Olmert government. Here, too, the change at the top of the Shin Bet played a key role.Cohen’s rationale for agreeing to release six Israeli Arabs was that a few of the ones requested by Hamas were old and not particularly dangerous. The agreement to release almost all of the Hamas prisoners from Gaza was made due to an assessment that their influence over Hamas would be limited.“There are 20,000 Izzadin Kassam members in Gaza, and another 200 are not going to make a huge difference,” Cohen explained.For now, the entire defense establishment is focused on implementing the deal and getting Schalit home. But after he returns to his family in Mizpe Hila, the tough questions will need to be asked: How come Israel failed for five years to create a viable military option to release him from Gaza, or other means of leverage over Hamas that could have forced it to agree to this deal earlier than now.Israel will also have to ask itself what may the toughest question of all: What happens next time? What happens after the next soldier is kidnapped? The Winograd Committee, established to probe the Second Lebanon War in 2006, wrote an appendix to its report in which it called on the government to set a clear policy for how it deals with kidnapped soldiers.This has yet to happen, and as long as Hamas and Hezbollah know that one Israeli is worth 1,000 prisoners, chances are they will try again.