Shin Bet security service director Yoram Cohen said Wednesday that the prisoner swap agreement reached between Israel and Hamas, with Egyptian mediation, to free Gilad Shalit included the best terms possible for Israel with regards to security.

Do you think the swap deal is fair? Head over to Haaretz.com on Facebook and share your views

"If there was a better alternative, operationally or via negotiations, perhaps we would have chosen it," Cohen said during a press briefing. "But I think we got the best deal in terms of security parameters. This was a difficult deal in terms of diplomacy, security and morals, but to bring our soldier home in the relevant time frame, negotiations were needed, and the other side lowered its demands significantly on all aspects."

Palestinian security prisoners to be released as part of the Gilad Shalit deal between Israel and Hamas include the murderers of kidnapped IDF soldiers Nachshon Wachsman, Ilan Sasportas and Ilan Saadon.

Other prisoners being released include the perpetrator of the Bus 405 Tel Aviv-Jerusalem attack in 1989, the terrorist who killed 10 Israelis in Wadi Harmiyeh north of Ramallah in 2002, the terrorist who brought the suicide bomber to the Sbarro restaurant in Jerusalem in 2001, and several perpetrators of the lynch in Ramallah in October 2000.

Among these prisoners, those from the West Bank will not be able to return to their homes and will be deported to the Gaza Strip or abroad.

Under the agreement, the release of Gilad Shalit is expected to take place in about a week, along with the release of 479 Palestinian security prisoners.

Of the released prisoners, 96 are West Bank residents who will be allowed to return to their homes. Fourteen East Jerusalem residents and six Israeli Arabs will also be allowed to return to their homes.

The released prisoners also include 131 Palestinians from the Gaza Strip.

Twenty-seven women, all the women imprisoned in Israel for security offenses, will be released. Two will be deported, one to Gaza and one to Jordan.

About half of the released prisoners, 203, will not be allowed to return to their homes. 40 will be deported abroad and the rest transferred to the Gaza Strip.

Of the deportees, 165 will be allowed to return to the West Bank in 10-25 years. The other deportees will never be allowed to return to the West Bank.

In two months, Israel will release another 550 prisoners that it chooses.

Of the 479 prisoners being released in the first stage, 279 were serving life sentences.

Cohen said that in the five years since Shalit was captured there was an unbridgeable gap between Hamas' demands and what Israel was willing to agree to. The situation began to change three months ago when it became clear that Hamas was ready to be flexible on which prisoners be released and on the demand that they be allowed to return to the West Bank.

The German mediator was not involved in the talks in recent months. Rather, Egyptian intelligence services managed the process. 

In exchange for Hamas' willingness to agree to a large number of deportees, as well as the fact that symbolic Hamas figures would not return to the West Bank, Israel agreed to release more East Jerusalem residents and Israeli Arabs, as well as 25 terrorists from a list that Israel had previously refused to release.

The final phase of talks got underway in Cairo last Wednesday, when Cohen and the head of Israel's negotiating team David Meidan met with Egyptian mediators while Hamas officials sat in an adjacent building.

The talks were renewed on Sunday morning, after Yom Kippur, and the agreement was signed on Tuesday morning at 8 A.M. It was immediately sent for government approval.