Jerusalem (CNN) -- Israel and Hamas leaders said Tuesday they have brokered a deal to swap roughly 1,000 Palestinian prisoners for Gilad Shalit, the Israeli soldier captured by Hamas more than five years ago.
Shalit is expected to return to Israel within a few days, Israeli Prime Minister Benjamin Netanyahu said at the start of an emergency Cabinet meeting called to discuss the soldier's release. The Cabinet later voted 26-3 in support of the swap.
"We will return Gilad healthy and whole to his family and all of Israel," the prime minister said. "The negotiations were difficult. ... We had to make difficult decisions but (the) correct one. With all the change taking place in the Middle East we did not know if a better deal or any deal would have been possible."
Netanyahu said on Twitter that the "arduous negotiations" brokered through Egyptian mediators resulted in a deal last Thursday and it was signed formally by Israel and the Palestinians Tuesday.
In a speech broadcast on Hamas-run Al-Quds television, exiled Hamas leader Khaled Meshaal said the prisoner exchange will involve the release of 1,027 Palestinian prisoners, including women.
"The deal will happen in two stages -- the first stage the release of 450 Palestinian prisoners, including 315 Palestinian prisoners that have one or many life sentences and the ones who are with high sentences. The second stage will include 550 Palestinian prisoners," he said.
The exchange will also include the release of 27 Palestinian female prisoners, Meshaal said.
Shortly after his speech, Al-Aqsa television, also run by Hamas, broadcast images of Palestinians celebrating the agreement in Gaza.
Hamas is the militant Palestinian movement that controls Gaza.
Of the 450 Palestinian prisoners to be freed during the first stage, 110 will go to the West Bank while 40 will go abroad, according to Mark Regev, Netanyahu's spokesman. The 550 prisoners scheduled to be released during the second stage will be freed two months later, he said.
According to Regev, jailed Palestinian lawmaker Marwan Barghouti is not among the prisoners Israel has agreed to release.
Palestinians captured Shalit in June 2006 after tunneling into the Jewish state and attacking an Israeli army outpost. Israel immediately launched a military incursion into Gaza to rescue Shalit, then 19, but failed to free him.
Since then, he has been held incommunicado by Hamas.
Netanyahu said he had updated Shalit's grandfather and parents, Aviva and Noam Shalit, about the developments.
"I told them that I am keeping my promise and I'm bringing their son and grandson home. I told them, 'I'm bringing your boy back,'" he told the Cabinet.
Palestinian Authority President Mahmoud Abbas, speaking in Colombia, said that he welcomed the agreement.
"We've been waiting for this deal. ... We wish for the release of all Palestinian prisoners from Israeli prisons," he said, the WAFA news agency reported.
In October 2009, Hamas released a tape of Shalit to prove he was still alive in exchange for the release of a number of Palestinian prisoners being held in Israeli jails. Since then, there has been no proof of life. There had been ongoing attempts to broker a deal to release Shalit, but all had failed.
Noam Shalit told CNN in June that it was time for the Israeli government to reach a deal with Hamas, no matter how high the price.
Following the Israeli Cabinet's vote on the swap, he thanked his son's supporters in Israel and around the world.
"For us, the story will only conclude when we will see Gilad coming home, going down the stairs into the house. Then we will be able to say that the circle has been completed," he said.
CNN's Kamal Ghattas, Kareem Khadder, Izzy Lemberg and Kevin Flower contributed to this report.