Updated at 2:56 a.m. Eastern.
JERUSALEM - In a much-anticipated prisoner exchange that could have broad implications, Israel and Hamas on Tuesday announced that an Israeli soldier abducted to Gaza five years ago would be swapped for about 1,000 Palestinians held by Israel and accused of militant activity.
Israel's government approved the deal early Wednesday after both Israeli Prime Minister Benjamin Netanyahu and Hamas leader Khaled Mashaal announced the agreement in televised comments.
The Cabinet approved the deal in a 26-3 vote, after a debate that lasted more than three hours.
Ahead of the vote, Israel's hardline foreign minister, Avigdor Lieberman, said he would oppose the deal, arguing that freeing convicted militants would lead to new violence. Netanyahu had implored his Cabinet to support the deal, saying it was the best Israel could hope for.
Netanyahu said the captured soldier, Sgt. Gilad Schalit, would return home within days. Mashaal, portraying the agreement as a victory, said the Palestinian prisoners would be freed in two stages over two months.
Hamas and Israel are bitter enemies. Hamas has sent dozens of suicide bombers into Israel, killing hundreds, and Israel blockaded Gaza after Hamas seized power there in 2007, carrying out a large-scale invasion in 2009 to try to stop daily rocket attacks on Israel. More than 1,500 Gaza Palestinians have been killed in Israeli raids and airstrikes since the soldier was captured.
In the northern Gaza town of Jebaliya, thousands of Hamas supporters flocked the streets, led by masked militants. Cars with loudspeakers played praise for Hamas. Thousands of other Gazans rushed to their border with Egypt, clutching Palestinian and Egyptian flags, tossing flowers and cheering.
Gaza's Hamas prime minister, Ismail Haniyeh, smiled as he threw candy to celebrating backers.
The deal maintains a decades-long tradition of lopsided exchanges that have come under increasing criticism in Israel -- and ends a period of tortured indecision by Israeli governments torn between securing the release of a single soldier and the risk that freed militants might return to violence that could cost many more lives.
"There is built-in tension between the desire to return a kidnapped soldier ... and the need to preserve the security of the citizens of Israel," Netanyahu said, in comments at opening the Cabinet meeting. "I believe we reached the best deal that we can reach at this time, a stormy time in the Middle East."
In agreeing to go ahead with the deal, the career hard-liner made a potentially fateful choice.
It gives Hamas, a militant group that rules the Gaza Strip, a victory that might strengthen its hand against the more moderate Palestinian President Mahmoud Abbas, whose Palestinian Authority runs the West Bank.
Mashaal said 1,000 male prisoners and 27 female ones would be released, the first 450 over the next week and the rest within two months. He said the released would include 315 prisoners serving life sentences, suggesting they were convicted of attacks that caused the deaths of Israelis.
Seeming to confirm Israel's fears, Mashaal said that those who are released "will return to ... the national struggle."
"This is a national achievement for the whole Palestinian people," Mashaal said, adding that he was pained not to be able to release the thousands of remaining prisoners held by Israel. The exact number of prisoners is under some contention, with the Palestinians citing 8,000 and Israel confirming about 5,000.
Yoram Cohen, head of Israel's Shin Bet security agency, said over the course of six secret rounds of talks in recent months, Hamas had backed down from key demands, including the release of some top militants. He said about 40 of the first group of prisoners would be exiled to other countries.
News of the deal set off wild celebrations at a protest tent erected by Schalit's family outside Netanyahu's residence in Jerusalem. Several hundred people danced in the street and waved flags with Schalit's image on it.
The soldier's father, Noam, has become a well-known public figure by pushing for his son's freedom.
The tiny structure is decorated with pictures of Schalit, as well as a large sign with the number 1,934, the number of days he has been in captivity. Schalit's parents sat in the tent, smiling as people flooded to the area and cars honked horns in excitement.CBS News foreign affairs analyst Pamela Falk says Noam Shalit came to the U.N. several times to try to gain access to his son, and to put pressure on Hamas for his release. On the most recent visit, on September 8 this year, the soldier's father said his family had received three notes from him during his five year imprisonment, and an audio tape and a video tape.
"The last sign of life we received from him was in September 2009, that was two years ago."
Germany had mediated a deal in June, Shalit's father said, but nothing came of it, Falk reports, until the new Egyptian government-brokered agreement that both sides agreed to, putting Egypt in a better position to negotiate a return to talks between Israel and the Palestinians in the future.
Not all Israelis were celebrating with Shalit's family.
Typical of the criticism was a statement by Almagor, a group representing victims of Palestinian attacks. "In the end Netanyahu has surrendered to Hamas," the group said. "The terrorists who are released are a danger to the citizens of Israel."
The plight of Palestinian prisoners is equally emotional among Palestinians. Virtually every Palestinian has a relative who has served time in an Israeli prison, and Palestinians routinely hold large demonstrations where they hold up posters of their imprisoned loved ones.
The very fact of any agreement between Israel and its archenemy seemed to offer a beguiling prospect of a new dynamic in the region.
To date, Hamas has not abandoned its ideology that calls for the destruction of the Jewish state. For its part, Israel has never accepted the violent Hamas takeover of Gaza in 2007. Though neither side hinted at changes in those basic policies, the prospect of even lukewarm relations developing between Israel and Hamas could open a new window for peace efforts.
The deal was also an important milestone for the new military authorities in Egypt, which both sides credited with brokering the deal and who emerge with a heightened aura of regional leadership.
Schalit was captured in a cross-border raid in June 2006 by Palestinian militants who burrowed into Israel and dragged him into Gaza after killing two other soldiers.
Little has been known about his fate since then, and Hamas has outraged public opinion in Israel by refusing to even allow Red Cross visits, releasing only a brief audio recording and a videotaped statement early in his five years in captivity.
Schalit's ordeal has become an obsession in Israel, where military service is mandatory and the public has identified with his family. Israel's Channel 2 TV said Schalit would be returned to Israel via Egypt.
Cohen, the Israeli security chief, said there was a turning point in July, when Hamas dropped its demands to free key imprisoned militants. He said the most prominent names, uprising leader Marwan Barghouti, faction leader Ahmed Saadat and Hamas bombmaker Abdullah Barghouti were not included.
Saadat was convicted of planning the assassination of an Israeli Cabinet minister in 2001. Barghouti was the top local commander of Fatah, the movement of President Mahmoud Abbas, when he was arrested in 2002 and convicted of a role in deadly attacks against Israelis. He is serving multiple life terms but is widely touted as a future Palestinian president.
Israel has been carrying out unequal prisoner swaps for decades, including handing over 4,600 Palestinian and Lebanese captives in 1983 in exchange for six captured Israeli soldiers. In 2008, it even freed Arab prisoners for the bodies of two soldiers killed by Hezbollah guerrillas in Lebanon.
Hamas is in a bitter rivalry with Abbas, who is enjoying a burst of popularity after defying Israel and the U.S. and seeking membership for the Palestinians at the U.N.
Abbas, traveling in South America, praised the deal. "We have waited for this for a long time. We demand that all prisoners be released from the Israeli prisons, and we appreciate the Egyptian efforts," he said.
Netanyahu is also eager for a domestic boost. The Israeli leader has faced growing criticism for a deadlock in peace efforts with the Palestinians, as well as a series of domestic protests over the country's steep cost of living. Bringing Schalit home could make Netanyahu a hero.