JERUSALEM — It was a potentially devastating blow to Benny Gantz, the former army chief battling mightily to depose Prime Minister Benjamin Netanyahu.
On Thursday, four days before the election — their third contest in under a year — a recording of Mr. Gantz’s top strategist privately denigrating Mr. Gantz’s courage and capacity to defend the state of Israel was broadcast on the evening news.
The remarks appeared to corroborate the heart of Mr. Netanyahu’s message to Israeli voters: that, regardless of Mr. Gantz’s distinguished military career, they would be risking their safety by entrusting it to him.
It is a powerful allegation in security-obsessed Israel, and in a race as tight as this one, it could help Mr. Netanyahu persuade voters who remain on the fence to look past Mr. Gantz’s main argument: that Mr. Netanyahu, who is awaiting trial March 17 on corruption charges, has lost the moral standing to lead.
But the disclosure of the leak’s origin on Friday cast it in an entirely new light — giving voters predisposed to mistrust Mr. Netanyahu ample new fodder, if not entirely mitigating the damage to Mr. Gantz.
The strategist, Israel Bachar, had in a year’s time helped Mr. Gantz, a career soldier but a political newcomer, create a new party, grow it into Israel’s largest and get it to within a few seats of clinching power.
Where the recording came from, however, was initially a mystery. The identity of Mr. Bachar’s interlocutor was not revealed when it was broadcast on Israel’s Channel 12 Thursday night.
Only on Friday, hours after Mr. Gantz had fired Mr. Bachar, did answers emerge — giving Israel’s long-running political drama its most bizarre plot twist yet.
A few weeks ago, it turned out, Mr. Bachar had gone to see a rabbi about a personal problem. He and the rabbi, Guy Havura of Ramle, spoke for hours. At times, their discussion turned to politics.
Rabbi Havura was secretly recording them the whole time.
Among other things, Mr. Bachar said that Mr. Gantz “hasn’t got the courage to attack Iran.”
“It goes to the core of Bibi’s claims,” said Tal Schneider, a political columnist for the Globes newspaper. “It’s a line from Bibi’s playbook.”
How that recording made its way to Israel’s Channel 12 has not been fully disclosed. But a possible route was quickly identified by other Israeli news media.
A lawyer for the prime minister named Amid Haddad is a student of the rabbi’s and meets with him frequently, Channel 13 reported.
On Wednesday, Rabbi Havura was a key participant at a meeting Mr. Haddad arranged for Mr. Netanyahu at a yeshiva in Tel Aviv.
During that meeting, Rabbi Havura led yeshiva students in a prayer for Mr. Netanyahu to win a governing majority of 61 seats in Parliament in Monday’s vote. In a video, Rabbi Havura could be seen gesturing to the yeshiva’s students “to pray strongly,” Walla news reported.
A day later, the recording made by Rabbi Havura was broadcast by Channel 12.
The story consumed much of the Israeli news media on Friday. “It’s got everything — crooked rabbis, leaks, a photo of the rabbi with Bibi the day before: It’s brilliant,” said Anshel Pfeffer, a political columnist for Haaretz.
On Twitter, some reached back to a blabby rabbi on an episode of “Seinfeld” to get across the sense of violation at play.
Mr. Pfeffer, a yeshiva student once himself, noted that Judaism contains no confession-like guarantee of confidentiality, and said that if the rabbi indeed leaked the recording, he could have reasoned that he was acting for the “greater good” of Israel.
Only the onset of the Jewish Sabbath, during which religious Jews do not use the telephone, brought the frenzy of reporting to a standstill. Neither Mr. Haddad nor Rabbi Havura, the founder of a charity for pediatric cancer patients, could be reached for comment.
Mr. Gantz sought to focus outrage on Mr. Netanyahu, calling Mr. Bachar the victim of “a planned ambush,” and likening Mr. Netanyahu to a gangster. “The mafia is here,” he wrote, showing a photo of the premier.
“Netanyahu has corrupted even the relationship of trust between a man and his rabbi,” Mr. Gantz wrote on Twitter. “Netanyahu, the pressure of your trial is reducing you to demeaning behavior even for you,” he added. “You’ve lost all inhibitions.”
Mr. Netanyahu’s party, Likud, said Mr. Bachar had been fired for telling the truth.
In a statement, Mr. Bachar did not specifically disavow his record remarks. He did praise Mr. Gantz as a “worthy leader” who had “greatly contributed” to strengthening Israel’s security “as a fighter, commander and chief of staff.”
Addressing the recording, he declined to go into detail, saying only that “the situation published is part of a campaign of fraud that has achieved a new record of humiliation.”