Israel’s president has asked prime minister Benjamin Netanyahu to try to form a governing coalition two weeks after last month’s election — the country’s fourth in two years — once again delivered a deeply fractured parliament.

Announcing the decision on television on Tuesday, President Reuven Rivlin admitted that no party leader had “a realistic chance of forming a government that will have the confidence of the Knesset”. But he indicated that it was his legal obligation to ask someone to do so.

After consulting with the 13 parties in the newly elected parliament, Rivlin said Netanyahu had “a slightly higher chance of forming a government,” but emphasised that it was “not an easy decision on a moral and ethical basis” given Netanyahu’s continuing corruption trial on charges of bribery, fraud and breach of trust.

Netanyahu and his coalition of rightwing and ultra-Orthodox allies fell several seats short of a parliamentary majority in the March 23 poll. A rival bloc of disparate parties ranging from pro-settler factions to leftists, united only by a desire to topple the long-serving Netanyahu, also failed to secure a workable majority.

Netanyahu was backed by 52 MPs in the 120-seat Knesset, while 45 supported opposition leader Yair Lapid. Two Arab-Israeli factions and former interior minister Gideon Saar’s New Hope party declined to support any candidate, while former defence minister Naftali Bennett of the pro-settler Yamina party recommended himself for prime minister.

Israel’s political and legal crises converged on Monday with the start of the presentation of evidence in Netanyahu’s trial. The premier was obliged to be in attendance in Jerusalem District Court to hear the lead prosecutor’s opening arguments as his own Likud party representatives were meeting Rivlin just a few kilometres away at the President’s Residence.

Netanyahu later gave an unplanned public address, slamming the country’s legal authorities for what he described as a “witch hunt” and “attempted coup.”

“This is how they try to overthrow a powerful prime minister from the right,” Netanyahu said. “What is happening is an effort to trample democracy . . . They are attempting to annul the will of the electorate.”

The prime minister now has 28 days to try to cobble together a workable governing coalition. His most likely option, according to analysts, is to sway Bennett back to his side and convince other far-right allies to accept the tacit support of the Islamist Ra’am faction — a move so far rejected by leading ultra-nationalist politicians.

If Netanyahu fails in this bid, then the task of forming a government could revert to Lapid. Speaking on Monday, Lapid, head of the centrist Yesh Atid party, indicated a willingness to join forces with Bennett in a power-sharing government, with Bennett serving first as prime minister.

Barring that scenario, the most likely outcome would be a fifth election and yet more political deadlock. “The state of Israel is not to be taken for granted. And I fear for my country,” Rivlin said when raising the possibility on Tuesday.