JERUSALEM/GAZA (Reuters) - Israel and Gaza's Hamas Islamist rulers agreed on Tuesday to swap more than 1,000 Palestinian prisoners for Israeli captive soldier Gilad Shalit, resolving one of the most emotive and intractable issues between them.
Israeli Prime Minister Benjamin Netanyahu, asking his cabinet to approve the lopsided swap and under constant public pressure to bring Shalit home, said the soldier would be reunited with his family "in the coming days."
Palestinians in the Gaza Strip greeted the agreement, brokered by Egypt and a German mediator, with celebratory gunfire. Hamas confirmed that it only remained to conclude technical arrangements for the exchange.
The breakthrough pact, after many false dawns in years of secret efforts to free Shalit since he was captured in 2006, has no direct bearing on Middle East peace negotiations.
But it was virtually certain to improve the climate for international efforts to restart peace talks.
Prospects for peacemaking have been clouded by Palestinian President Mahmoud Abbas's request for UN recognition of a Palestinian state and Israeli settlement expansion which Abbas has said must stop if negotiations are to begin again.
A source involved in the talks said the long elusive pact had been mediated by Egypt, playing a role which is likely to strengthen Israel's ties with Cairo, which have suffered since the fall of Egyptian leader Hosni Mubarak in a revolution this year.
Hamas leader Khaled Meshaal said Israel will release 1,027 prisoners in two stages. Within a week, 450 will be swapped for Shalit and the rest will be freed two months later. Twenty-seven women are among those on the release roster.
It was not immediately clear how many of the prisoners were jailed for attacks that caused Israeli casualties. Under Israeli law, opponents of their release have at least 48 hours to appeal to courts to keep them behind bars.
In tandem with a public campaign waged by Shalit's parents for his freedom, relatives of Israelis killed in Palestinian attacks have lobbied Netanyahu not to give in to Hamas by releasing prisoners with blood on their hands.
There are about 6,000 Palestinians prisoners in Israeli jails. They are regarded as heroes in what Palestinians call their struggle against Israeli occupation and quest for statehood.
"We are happy with this great achievement and we thank our God for that. But our happiness is mixed with sorrow because we were not able to gain the freedom of all prisoners," Meshaal said in a televised address from Damascus.
Israeli television quoted Netanyahu as telling Shalit's parents that ever since he took office three years ago "I've been waiting for the chance to make this telephone call" to inform them of the deal.
Shalit's family, which has maintained a vigil in a protest tent near Netanyahu's Jerusalem home for months, had accused him of not doing enough to secure his release.
Announcing to his cabinet, and television cameras, that a deal had been signed earlier in the day, Netanyahu said he feared time was running out for Shalit amid political upheaval in the Arab world.
"I believe we have reached the best agreement possible at this time when storms are raging in the Middle East. I don't know if we could have reached a better agreement, or even achieved one at all, in the near future," he said.
"It's possible that this window of opportunity would have closed for good and we never would have brought Gilad home."
The wife of Marwan Barghouti, a charismatic activist seen as a future Palestinian leader, told Reuters in the West Bank that she was eagerly awaiting word that he will be included in the prisoner swap.
In Gaza the families of men jailed for life by Israel waited to see if their names would be on the list.
Israel has carried out several lopsided prisoner swaps in the past, notably in 1985 when hundreds of Palestinian prisoners were freed in exchange for several soldiers captured by a guerrilla group in Lebanon.
The ordeal of Shalit, a fresh-faced corporal, transfixed Israel after the tank gunner was captured by militants who tunneled their way out of Gaza and then forced him back over the border.
He was 19 at the time and had begun his mandatory three-year army service nearly a year previously.
Shalit, who also holds French citizenship, was last seen in a videotape released by his captors in September 2009 showing him looking pale and thin.
He received no visits from the International Committee of the Red Cross, despite many appeals.
(Reporting by Nidal al Mughrabi, Allyn Fisher-Ilan, Ali Sawafta, Jeffrey Heller and Douglas Hamilton; Writing by Jeffrey Heller and Douglas Hamilton; Editing by Andrew Heavens)