JERUSALEM - Hundreds of Palestinian prisoners agreed Monday to halt a weeks-long hunger strike in exchange for promises of better conditions, ending a standoff that left several participants clinging to life and drew thousands of Palestinians to the streets in shows of solidarity.

The Palestinians won key concessions in a deal mediated by Egyptian officials, including more family visits and limits to a controversial Israeli policy that can imprison people for years without charge. In return, Israel extracted pledges by militant groups to halt violent activities, and prevented the potentially explosive scenario of prisoners dying of hunger.

The fate of the prisoners is an emotional issue for Palestinians, a group in which nearly everyone has a neighbor or relative who has spent time in an Israeli jail. Hundreds of Palestinians took to the streets of the West Bank and the Gaza Strip each day to show solidarity with the inmates, often holding pictures of their imprisoned loved ones.

Praise and thanks

In Gaza City, Palestinians cried for joy and praised God over blaring loudspeakers at news of the deal. "God is Great! To God is our thanks!" they chanted. Thousands waved the Palestinian flag, distributed sweets, and prostrated themselves in thanks. The deal ended one of the largest mass strikes of Palestinian prisoners. Two men launched the strike on Feb. 28, refusing food for 77 days. At least 1,600 other Palestinian prisoners, more than a third of the prison population, joined the strike on April 17, fasting for 27 days.

With the Palestinians already planning demonstrations for their annual day of mourning Tuesday, both sides were eager to reach accord to avoid spreading anger over the issue. Palestinians use May 15 to commemorate the suffering they say resulted from Israel's establishment 64 years ago, a day they call the nakba, or catastrophe.

"The prisoners have proved to the whole world that empty stomachs are more powerful than any ruler or oppressor," said a spokesman for Gaza's Hamas rulers, Fawzi Barhoum.

Israel agreed to let about 400 prisoners from Gaza receive family visits for the first time since 2006, according to terms of the deal as confirmed by Israeli and Palestinian officials. Israel halted the family visits after Hamas captured soldier Gilad Shalit in 2006. But the soldier was returned in a prisoner swap in October and Palestinians wanted the ban to end.

'A simple right'

"We were on strike for a simple right: to visit our children. My dream was that Ali would be freed - but at least now I can see him," said Nidal Sarafiti, a 64-year-old Gazan, speaking of his son, who has served seven years of an 18-year sentence for involvement in militant activity. He said he hadn't seen his son since he was imprisoned.

In response to another demand by prisoners, Israel agreed to ease its policy of "administrative detention" lasting months, even years, without charge.

The Palestinian minister for prisoner affairs, Issa Qaraqe, said the 300 detainees held without charge would have their files reviewed after six months. The detentions can be extended only if Israel presents concrete evidence against them to a military court.

Israel's Shin Bet security agency said the prisoners pledged to stop helping to plan and conduct attacks from inside Israeli jails via networks that enable contact with the outside world. It also said militant groups' commanders outside the jails had made a commitment "to prevent terror activity."