Israel's Prime Minister Benjamin Netanyahu on Thursday called on his main rival in an inconclusive election to form a unity government.

For the second time in less than six months, Israelis failed Tuesday to convincingly back a prime minister in an election that highlighted the Jewish state's complex secular-religious divide and pitted its longest-serving leader, Netanyahu, against Benny Gantz, the hawkish former head of Israel's military.

Netanyahu, 69, was hoping to win an outright majority that would have seen him secure a record fifth term. A former commando whose tenure has been defined by promises to keep Israel secure and prosperous, while sidelining Palestinians, Netanyahu could see his decade-long dominance of Israel's polarized politics end.

Trump factor: Donald Trump proves he's the 'King of Israel'

"Throughout the campaign I called for a right-wing government, but unfortunately the election results show that’s not possible," Netanyahu said in a video statement. "Therefore there is no choice but to form a broad unity government."

Gantz, 59, has bragged about flattening entire residential neighborhoods during two wars Israel fought with Palestinians in the Gaza Strip.

Partial results predicated that neither politician's party secured a majority, meaning that in order for either to form a government each would need to enter into a coalition deal with opposition parties. Forming a coalition could take days or weeks. Netanyahu failed to form a government in a vote in April, which set up Tuesday's election do-over.

With nearly all votes counted, the centrist Blue and White party stood at 33 seats in Israel’s 120-seat parliament. Netanyahu's conservative Likud stood at 31 seats.

"Everyone will need to get off their high horse to prevent elections for the third time," Likud lawmaker David Bitan told Israeli Army Radio. "Blue and White’s desire for a unity government under their terms will not work."

Gantz has appeared to reject the idea of sharing power with Netanyahu.

Both parties were meeting with allies in the vote’s aftermath and the focus will soon shift to President Reuven Rivlin, who will consult with all parties in the coming days and select the candidate who he believes has the best chance of putting together a coalition. The candidate has 42 days to do so and, if he fails, the president can give another candidate 28 days to form a coalition. If that fails, the president can assign another parliament member the task of building a government, or he can call new elections. Rivlin promised he will do everything in his power to prevent a third election.

One option for Netanyahu or Gantz would be seek to do a deal with the right-wing Yisrael Beitenu party, headed by Avigdor Lieberman, an immigrant from the former Soviet Union who is also a settler, an Israeli Jew who lives on land claimed by Palestinians. Settlements are considered to be a major obstacle to peace in the long-festering conflict between Israelis and Palestinians that has been running more than 70 years. It's possible that a third vote could also be called.

Or Netanyahu could try to form an alliance with ultra-Orthodox parties.

Ahead of the contest, Netanyahu attempted to energize his center-right base by appealing to voters' anxieties over Iran, the role of religion in schools, Arab Israeli minorities and the country's position on settlements – communities of Israeli Jews that build homes on Palestinian-claimed land in the West Bank. "Right now, we're losing," he said in a Sunday night campaign video. "If you go out and vote Likud, we'll win."

He has also repeatedly boasted of his close relationship with President Donald Trump, who has undertaken a series of high-profile, pro-Israel actions from moving the U.S. Embassy from Tel Aviv to Jerusalem to recognizing the Golan Heights. Huge billboards of Netanyahu and Trump side-by-side are plastered all over the country.

Among major industrialized powers, only Russia's President Vladimir Putin, Recep Tayyip Erdogan of Turkey and German leader Angela Merkel have led for longer than Netanyahu. However, his tenure in recent years has equally been defined by a series of corruption probes that are looming over him once he leaves office. Among the allegations are bribery, fraud and breach of trust. Netanyahu disputes the allegations.

Netanyahu is due to face a pre-indictment hearing within weeks, which provided him with another reason to want to secure a majority: An outright victory would have given him the ability to pass a law that would give him immunity from prosecution.

Contributing: Associated Press