But they had been planning to cooperate to push through legislation to stop Mr. Netanyahu from securing a fifth term, by enacting term limits or by barring an indicted lawmaker from forming a government.

In the end, however, Mr. Netanyahu’s almost nightly appeals to Mr. Gantz to join him — during televised addresses about the country’s response to the virus — appeared to wear down Mr. Gantz’s resolve.

Mr. Netanyahu has proposed a three-year government in which he would stay on as prime minister for the next 18 months and Mr. Gantz would take over for the next 18. Alternatively, Mr. Netanyahu has floated the idea of a temporary emergency government for the next six months under his leadership, to be followed either by a new deal for a unity government or a fourth election.

Mr. Gantz did not say on Thursday whether he supported either of these proposals.

Thursday’s endgame was particularly head-spinning, even for the hurly-burly of Israeli politics.

Mr. Gantz went from petitioning the Supreme Court on Wednesday to censure the previous speaker, Yuli Edelstein — a Netanyahu ally who resigned rather than allow the election of a new speaker — to accepting Mr. Edelstein’s support in the Thursday vote that elected Mr. Gantz as speaker.

Mr. Netanyahu’s conservative Likud party had issued an ultimatum that if Blue and White nominated its original candidate for speaker, Meir Cohen, that would spell the end of unity talks. Mr. Cohen had been expected to advance legislation blocking Mr. Netanyahu from serving another term.

Mr. Gantz’s acquiescence to that demand — by nominating himself instead — prompted howls of denunciation in Parliament from his partners in the center and left. They said that Mr. Gantz had dashed the hopes of his voters to end Mr. Netanyahu’s career and betrayed his own countless campaign promises never to serve under an indicted prime minister, all over an empty threat.