Israelis and Palestinians have welcomed the announcement of a deal to free captured Israeli soldier Gilad Shalit in exchange for Palestinian prisoners.
Crowds of Israelis took to the streets of Jerusalem in celebration at the news, while similar scenes were played out among Palestinians in Gaza.
The deal was announced on Tuesday by the Israeli and Palestinian leaders.
Under the terms, more than 1,000 Palestinians and Sgt Shalit, held since 2006, will be freed, beginning in days.
Sgt Shalit, aged 19 at the time, was snatched in a cross-border raid by Hamas militants who tunnelled from Gaza into Israel.
On-off negotiations for his release have taken place for several years.
At an emergency meeting on Tuesday night, Israel's cabinet voted overwhelmingly to accept a final deal.
"This is a tough decision," said Israeli Prime Minister Benjamin Netanyahu.
"I believe we reached the best deal we could at this time of turbulence in the Middle East. I do not know if in the foreseeable future we will be able to reach a better deal, or any deal at all."
In Jerusalem, hundreds of young Israelis - many carrying pictures of Sgt Shalit - danced and sang in the streets following the surprise announcement.
"I think it's a deal that should happen and I'm sorry it didn't happen many many years ago," a Jerusalem resident, Nachum, told Reuters news agency.
"Every human being must be for the deal."
Yarra Vinkler, the girlfriend of Gilad Shalit's brother, told the BBC the family were relieved.
"We just congratulated the government, we thank them that it finally happened."
In Gaza, Hamas said tens of thousands of people took to the streets in celebration over the imminent Palestinian prisoner release.
Witnesses described jubilant crowds firing guns into the air and honking car horns.
Hamas chief Khaled Meshaal, speaking from exile in Syria, said the deal was "a great achievement, a qualitative success".
Hamas spokesman Sami Abu Zuhri called the agreement "a cause for national celebration", Reuters reported.
The breakthrough was also welcomed by French President Nicolas Sarkozy, who telephoned the father of Sgt Shalit, an Israeli-French national, to express his "joy that Gilad will soon be released", AFP news agency said.
The BBC's Jon Donnison in Jerusalem says both the Israeli government and Hamas will try to make political capital out of the deal.
In Israel most families have relatives in the military and the plight of Gilad Shalit, one of the best known faces in the country, has touched Israeli hearts, he says.
Hamas argue his case is no different though from the approximately 6,000 Palestinians held in Israeli jails, our correspondent adds.
Several high-profile Palestinian prisoners have been excluded from the release deal, a senior Israeli official said.
Despite broad approval among Israelis, some have criticised the agreement.
"You can't bring an entire country to its knees, that's just crazy. It's complete surrender," former Israeli army chief rabbi Brig Gen Avichai Ronsky told Israeli newspaper Yediot Aharonot.
Under the deal, Israel will free 1,027 Palestinians in two stages - 450 initially, then 577 in two months' time, following Gilad Shalit's release.
The process is likely to begin early next week.