Finally, five years and four months after Mr. Shalit was captured, their back channel bore fruit.

Mr. Shalit was released in October 2011, in exchange for more than 1,000 Palestinian prisoners.

The final deal was overseen by David Meidan, a senior Israeli intelligence officer. But according to Mr. Meidan, it would not have been possible without the years of conversations between Mr. Baskin and Mr. Hamad.

“The key word is trust,” Mr. Meidan said in an interview. “They had trust between them. Ghazi Hamad trusted Gershon.”

In the years since, the two men remained in touch, trying unsuccessfully to negotiate subsequent hostage swaps and attempting to forge a long-term truce. When a journalist for The New York Times sought to meet Mr. Hamad during a relatively calm period in early 2021, it was Mr. Baskin who secured the interview.

Even after Oct. 7, the two men talked, discussing the fate of the hostages Hamas had abducted that day.

But something had changed, Mr. Baskin said.

Once capable of criticizing Hamas, Mr. Hamad now seemed in denial about the extent of the group’s atrocities, Mr. Baskin said.

By Oct. 22, Mr. Hamad had begun to publicly describe the attacks as a natural response to Israeli aggression.

“What do you expect the Palestinians to do?” Mr. Hamad asked in an interview with The Times that day, reeling off a list of actions taken by Israel — including its continued occupation of the West Bank — that he said justified Hamas’s violence.

Asked whether he feared that his attitude might cost him his relationship with Mr. Baskin, Mr. Hamad appeared to stumble momentarily.

“Say again?” he said at the mention of Mr. Baskin. “What?”

Then he regained his composure — and doubled down.

Within a week, Mr. Hamad had called for Israel’s annihilation and Mr. Baskin had ended their relationship.

Contacted again by The Times, Mr. Hamad declined to comment in detail on their falling out or why he had hardened his position.

Azzam Tamimi, a historian of Hamas who knows Mr. Hamad well, said that Mr. Hamad might have been shocked by the destruction caused by Israel’s counterattack. Although Mr. Hamad had left Gaza for Lebanon weeks before the war, many of his relatives and colleagues are still inside the enclave.

“Suddenly, he lost family members, he lost many of his friends,” Mr. Tamimi said. “Probably that’s the issue.”

Then again, Mr. Hamad was never as moderate as his interlocutors wanted to believe, Mr. Tamimi said. By calling for Israel’s destruction, “He was really expressing sincere feelings,” Mr. Tamimi said.

“Nobody should be under the illusion that someone that senior in Hamas is willing to recognize Israel’s right to exist,” Mr. Tamimi added.

Hwaida Saad contributed reporting from Beirut, Lebanon.