Centrist candidates strike an alliance in a bid to unseat the prime minister

If elected, Benny Gantz, a retired Israeli army chief, and Yair Lapid, a former TV anchor turned parliamentarian, agreed to take turns at running the country, they said in a statement Thursday. Mr. Gantz would serve as prime minister for the first 2½ years, and Mr. Lapid would take over for the rest of the four-year term.

It also comes at a vulnerable moment for Mr. Netanyahu, who is expected to be indicted on corruption charges later this month. He will have a chance to defend himself in a hearing before charges are formally filed, and he has vowed to stay in power and to fight them. He doesn’t have to resign unless convicted. Mr. Netanyahu has denied wrongdoing..

Opinion polls project a tight contest, but some indicate that Mr. Gantz’s Israel Resilience party and Mr. Lapid’s Yesh Atid party could together secure more seats in Israel’s parliament than Mr. Netanyahu’s Likud.

“The new ruling party will bring forth a cadre of security and social leaders to ensure Israel’s security and to reconnect its people and heal the divide within Israeli society,” the parties said in a statement.

The two parties also said they would add former Israeli army chief Gabi Ashkenazi to their slate. Mr. Ashkenazi is seen as an important player in attracting votes from the right, which will be important if Messrs. Gantz and Lapid are to unseat Mr. Netanyahu.

Both Mr. Gantz and Mr. Lapid are running as anti-Netanyahu candidates, while emphasizing a commitment to addressing social problems in Israel like education, housing, health care and traffic.

They have struck a more moderate tone than Mr. Netanyahu on handling relations with the Palestinians. Before the agreement, Mr. Lapid’s camp said it was unsure whether Mr. Gantz supported a two-state solution to the Israeli-Palestinian conflict, citing at least one in his party who has opposed it in the past.

Mr. Netanyahu’s Likud party said the election would be a choice of “either a left-wing government of Lapid-Gantz with preventative support from the Arab parties, or a right-wing government with Netanyahu at its helm.”

As an alliance became more likely, Mr. Netanyahu issued statements and videos painting Mr. Gantz and Mr. Lapid as weak and leftist, while describing himself and his party as strong and right.

.. Israeli politicians must submit their party lists to Israel’s Central Election Committee by Thursday. Those lists must disclose whether the politicians will run as one ticket.

.. “For the first time since 2009 we have a competitive race for the premiership,” said Yohanan Plesner, president of the Jerusalem-based Israel Democracy Institute. “The main question is whether this new list can lure or be attractive enough for some center right and soft right voters. This is probably the question that will determine the outcome of the election.”

Mr. Gantz entered politics late last year, brandishing his security credentials but saying little about his policy positions to try to lure a broad swath of the electorate. He has consistently polled second to Mr. Netanyahu and his Likud party.

Mr. Lapid’s party finished second in the 2013 elections, the first contest after it was created, but has slid in the polls ever since. Mr. Lapid served for a year as the finance minister in Mr. Netanyahu’s government.