Since talk about a possible prisoner swap to free hostages held in Gaza began circulating weeks ago, Nawaf Salaymeh and his family had been anxiously waiting to hear if his son and two nephews would be among the Palestinian minors who would be released from Israeli detention.

“We were so worried about our sons,” said Mr. Salaymeh. “And then finally, relief came.”

The three teenagers, all from East Jerusalem, are on the list of 300 names Israel says it is considering for release. Under a deal reached early Wednesday by Israel and Hamas under mediation by Qatar, 150 of those on the list are to be released over four days in exchange for the release of 50 Israeli hostages kept in Gaza and a temporary pause in fighting.

The accusations against nearly one in three prisoners included throwing stones, a New York Times analysis showed.

Mr. Salaymeh’s son Ahmad, 14, and nephews Moataz, 15, and Mohammad, 16, were detained together in July. The Israeli police accused Ahmad “of throwing stones, causing serious bodily injury, maliciously or negligently causing damage to property, and hostile sabotage activity.” Moataz and Mohammad were also detained for throwing stones.

The family said that the boys were among a group of youths who threw stones at the vehicles of residents of a nearby settlement who regularly drove around their neighborhood to “provoke them,” and hurl insults at them.

Israel annexed East Jerusalem from Jordan after the Arab-Israeli war of 1967, a claim not recognized by most countries, which consider it occupied territory. Since then, several Israeli settlements were built in and around the city’s Palestinian neighborhoods to cement Jewish control over the territory.

The family lost contact with the boys on Oct. 7, according to Mr. Salaymeh, when Israel imposed an emergency lockdown on prisons that included bans on visits and phone calls with inmates. The Israel Prison Service said that the lockdown was imposed “due to the national security situation and the threats to the safety of facilities, staff, and civilians.”

“We don’t know anything about our son,” Mr. Salaymeh said. “Was he tortured or transferred to another prison or put in solitary confinement? Did he even have a mattress to sleep on, a blanket to keep him warm, or food?”

Credit…Nawaf Salaymeh

A coalition of Israeli and Palestinian rights groups said in a statement last month that the wartime lockdown denied prisoners “their fundamental rights” amid reports of “extended periods of electricity and water disconnection, restrictions on essential medical care” and “hours of extreme overcrowding.” The groups added that there were “harrowing reports of inhumane treatment.”

But even before the lockdown, the family saw the boys almost exclusively in court, because, Mr. Salaymah said, many requests to visit them were denied.

At one September afternoon hearing, the boys’ teary-eyed mothers waved from a distance as they were escorted by police officers into the courtroom with their hands shackled. The boys’ older sisters were not allowed in — they stayed outside, glued to their phones, waiting to be sent videos with a glimpse of them.

The prospect of reuniting with the three has brought the family enormous relief, but Mr. Salaymeh said that, if indeed they were freed in the exchange for hostages, there would be no celebration.

“How can we celebrate when our boys were released at the expense of the blood of the martyrs in Gaza?” he said. “We hoped that the homecoming of our sons would be during a time without bloodshed, so we could feel joy.”