A Palestinian soccer player jailed by Israel since 2009 agreed to end his months-long hunger strike late Monday, in exchange for treatment in a hospital and an early release.

Mahmoud Sarsak, who has refused food for several months, will be released from detention July 10 and return to Gaza, his lawyer said Monday.

Sarsak, a former player for the Palestinian National soccer team, became a cause célèbre for Palestinians and sports figures around the world as his fast wore on.

The deal to free Mahmoud Sarsak would end the longest hunger strike ever launched by a Palestinian prisoner held by Israel. In a symbolic act, Sarsak, who has shed nearly half his normal weight, ate a small piece of chocolate on Monday evening to show the strike was over.

Sarsak began his hunger strike some three months ago, along with nearly 1,600 other Palestinian prisoners, over prison conditions and the administrative detention policy. All but a handful of the detainees agreed to end their fast in May after Israel promised to ease prison conditions.

Though he intermittently took in milk and a glucose drip, doctors said Sarsak’s fast had taken a harsh toll on his body.

“There had been a substantial deterioration in his health and he needs special care. He will not return to prison,” said Mohamed Jabarin, Sarsak’s lawyer, according to the Reuters.

Sarsak was picked up by Israel in Gaza in 2009 for alleged ties to the Islamic Jihad terror outfit.

Palestinians have hailed hunger strikes as the first effective means in years of exerting pressure on Israel. The protests, which brought several prisoners close to death, Sarsak among them, have also drawn attention to Israel’s practice of holding Palestinians without charges or trial, in so-called administrative detention.

Among those held without trial or charges, Sarsak is a special case. Israel has imprisoned him as an “unlawful combatant,” a status with even fewer legal rights than those of administrative detainees, according to the Israeli rights group B’Tselem. There’s a legal review every six months, but the burden proof is on the prisoner to show he is no longer dangerous, the group said.

The designation of “unlawful combatant” is used for detainees from abroad, and Israel places Gaza in that category. Israel says it cut all ties with Gaza when it withdrew in 2005, after 38 years of occupation. After the takeover of Gaza by the Islamic militant Hamas, Israel declared the territory a “hostile entity.”

Sarsak is currently the only “unlawful combatant” held in Israel, according to the Israel Prisons Authority.

Israel’s Prisons Authority spokeswoman Sivan Weizman declined comment Monday.