JERUSALEM (AP) — Israel’s president on Wednesday asked Prime Minister Benjamin Netanyahu to form a new government, giving the longtime leader the difficult task of breaking a post-election deadlock that has paralyzed the country’s political system.

After a divisive campaign, Netanyahu called for a “broad unity government” with his chief rival former military chief Benny Gantz. But he faces an uphill struggle, with his future clouded by a likely corruption indictment and his opponents opposed to sitting with him.

President Reuven Rivlin announced his decision late Wednesday after a second meeting aimed at brokering a unity deal between Netanyahu and Gantz ended without an agreement.

Standing alongside Rivlin, Netanyahu said it was clear that neither his Likud party nor Gantz’s Blue and White could put together a coalition on its own, and that the only option was to band together.

“The two of us cannot form a government unless we are together,” he said. “The order of the moment is a unity government, a broad national unity government that is formed quickly.”

He said the country faced great security challenges, highlighted by Iran, economic challenges and the “great opportunity” of settling its borders when President Donald Trump presents an expected Mideast peace plan.

In a statement, Gantz appeared to rebuff Netanyahu, citing the Israeli leader’s legal problems.

“Blue and White, led by me, does not agree to sit in a government whose leader is facing a severe indictment,” he said. “This issue, among a number of other critical factors, is more important to us than any delegation of ministerial posts or rotation.”

Rivlin said his decision was not a solution and that both candidates were responsible for resolving the political impasse.

“The Israeli people need to know that a government can be established,” he said. “It is true that everyone will have to compromise. But if a government is not formed, it is the citizens of Israel who will pay the greatest price.”

Rivlin said his decision was not a solution, and that both candidates were responsible for resolving the political impasse.

Although Rivlin’s duties are mostly ceremonial, he is responsible for choosing the candidate he believes has the best chance of forming a coalition government.

That is usually a straightforward task. But in last week’s election, neither Netanyahu’s Likud party nor Gantz’s centrist Blue and White secured the required parliamentary majority needed to form a government.

According to final official results announced Wednesday, Blue and White finished first with 33 seats in the 120-seat parliament, just ahead of Likud’s 32 seats. Even with the support of smaller allies, both parties are short of the required 61-seat majority.

A total of 55 lawmakers have recommended that Netanyahu lead the next government, while 54 have lined up behind Gantz. Rivlin said that after exploring all options, he concluded Netanyahu had the better chance of forming a government.

Netanyahu now has a preliminary 28-day period to try to broker a deal. But his odds of success appear to be slim.

Both sides agree a unity deal is the only way out of the deadlock, but they have disagreed over who should head it.

Gantz has repeatedly said he will not sit with Likud as long as Netanyahu is at the helm. Facing a likely corruption indictment in the coming months, Netanyahu is desperate to remain as prime minister.

Israel’s attorney general has recommended charging Netanyahu with bribery, fraud and breach of trust in a series of scandals.

Netanyahu, who denies any wrongdoing, is to appear at a hearing with the attorney general next week, after which a final decision on charges is expected. Legal experts say the likelihood of an indictment is high. Although Netanyahu would not be required to step down if charged, he will face heavy pressure to do so.

Another key player throughout the process will be Avigdor Lieberman, whose Yisrael Beitenu party controls eight seats. Lieberman refused to endorse either candidate and is pushing for a unity government.

Without a unity deal, Netanyahu will have a tough time putting together a coalition. The secular Lieberman says he will not be part of a government that includes Netanyahu’s ultra-religious allies.

Netanyahu now has 28 days to form a coalition, and Rivlin having discretion to give him an additional 14 days to do so.

If Netanyahu fails, Gantz would likely be given an opportunity. And if that fails, a majority of parliament members could offer a third name to be prime minister. And if that fails, Israel would be forced into holding its third election in less than a year.

Last week’s election was triggered after Lieberman refused to join Netanyahu’s coalition following April elections, citing what he said was excessive influence of religious parties. Instead of giving Gantz a chance to form a government, Netanyahu dissolved parliament and ordered a new election.

Netanyahu said that if he fails this time, he will allow Rivlin to choose another candidate.

“The nation does not want another election,” Rivlin said.