JERUSALEM — Hundreds of hunger-striking Palestinian prisoners ended their 40-day fast on the first day of the month-long Muslim holiday of Ramadan, after reaching a compromise with Israel for additional family visits, Israeli and Palestinian officials said.

Israel prison service spokeswoman Nicole Englander said the inmates declared an end to the strike Saturday morning. She said it came after a deal was reached with the Palestinian Authority and the Red Cross for prisoners to receive a second family visit each per month.

Hundreds of prisoners observed the strike they said was aimed at improving prison conditions.

The hunger strike had evolved into one of the longest such protests with this many participants since Israel’s 1967 capture of territories Palestinian seek for their state in the West Bank, east Jerusalem and the Gaza Strip.

Englander said 1,578 prisoners participated in the hunger strike overall, some fasting intermediately, and 834 ended their fast Saturday. She said 18 were being treated in hospitals.

Many Israelis view the prisoners as terrorists and have little sympathy for their demands. More than 6,000 Palestinians are currently in prison for offenses linked to the Israeli-Palestinian conflict, for charges ranging from stone-throwing to weapons possession and attacks that killed or wounded Israeli civilians and soldiers in bombings, shootings and other violence.

Several hundred are being held without trial in so-called administrative detention. Israel has defended the practice as a necessary tool to stop militant activity, including preventing deadly attacks.

Critics condemn it because there are no charges and judges can extend the detentions. They add that the practice is overused.

Palestinians rallied behind the hunger strikers as national heroes, relishing a rare break from deep divisions between two rival political groups, the Islamic militant group Hamas which runs Gaza and Fatah, the movement of Western-backed Palestinian President Mahmoud Abbas who administers autonomous enclaves in the Israeli-occupied West Bank.