Israeli Prime Minister Benjamin Netanyahu has launched a legal challenge to the government formation effort being led by hardline right-wing politician Naftali Bennett and his potential coalition government partner, centrist politician Yair Lapid. In a letter to the legal counsels of the presidency and parliament, Mr Netanyahu's conservative Likud party said Mr Lapid was not authorised to cede the premiership to Mr Bennett. But President Reuven Rivlin's office said in response that there was no legal merit to Likud's claim because Mr Lapid would be sworn in as "alternate prime minister" to serve as premier as part of the rotation. It accepted Likud's argument that Mr Lapid must provide the president with full details of the new government and not just announce that he has clinched a coalition deal. The challenge emerged after Mr Lapid said that obstacles remain before the diverse coalition of groups can agree on a political compromise to form a government. Mr Lapid, a secular centrist, is locked in talks with the right-wing nationalist Mr Bennett on the terms of a "change alliance" that also hinges on an array of other parties before a Wednesday midnight deadline. A former TV anchor, Mr Lapid's chances of success rose when tech millionaire Mr Bennett – despite their ideological differences – said on Sunday that he would join a "national unity government" in which the two men would take turns to serve as premier. A viable anti-Netanyahu coalition would still need the support of other parties and politicians to gain a majority of 61 seats in the 120-member Knesset, Israel's legislature. While Mr Lapid warned of remaining hurdles, he also sought to strike a cautiously upbeat note. "We'll have to overcome them together," he told members of his Yesh Atid party. "That's our first test – to see if we can find smart compromises in the coming days to achieve the greater goal." Mr Netanyahu, who has been in power for the past 12 years, following an earlier three-year term, has been fighting for his political life. On Sunday he warned of "a left-wing government dangerous to the state of Israel". The 71-year-old is Israel's longest-serving prime minister and the first to face criminal charges while in office – on fraud, bribery and breach of trust charges. He denies these charges. Mr Netanyahu lashed out at Mr Bennett, accusing him of "the scam of the century" for running on a right-wing platform, but then joining a prospective government that includes liberal parties. Mr Lapid, 57, is seeking to cobble together a diverse alliance that would include Mr Bennett, 49, a supporter of Jewish settlements in the occupied West Bank, as well as Arab-Israeli lawmakers. In order to build such an anti-Netanyahu bloc, he must sign individual agreements with seven parties, whose members would then vote in parliament to confirm the coalition. Among them are the centrist Blue and White alliance of Defence Minister Benny Gantz, and the hawkish New Hope party of Mr Netanyahu's former ally Gideon Saar. Mr Bennett allowed "us to make the change we are looking for in Israeli politics, which makes him qualified to be the next prime minister", Mr Gantz said on Monday. Avigdor Lieberman's pro-settlement Yisrael Beiteinu party, the historically powerful centre-left Labour Party and the dovish Meretz party would also join. Mr Netanyahu's conservative Likud party won 30 seats in the last election on March 23, the best result of any party, but far short of a majority. In a last-ditch bid on Sunday, Mr Netanyahu offered a three-way power-sharing deal to his rivals Mr Bennett and Mr Saar – but Mr Saar refused. Mr Bennett accused Mr Netanyahu of seeking to take down the political right and "the whole country with him on his personal last stand". Mr Lapid's party, with 17 seats of its own, had mustered a total of 51 votes of support from left, centre and right-wing parties, before Mr Bennett joined him. Mr Bennett's Yamina bloc has seven seats, but one legislator swore he would not co-operate with the anti-Netanyahu camp. To win the backing of four more lawmakers, needed to achieve the required 61 seats, Mr Lapid is counting on parties representing Arab citizens of Israel, which have not yet announced their intentions. It is unclear if they will ultimately agree to back the coalition with Mr Bennett, who previously directed the Yesha Council that represents Jewish settlers in the occupied West Bank. If any of the Arab members of the Knesset ultimately join the government in a deal it would be the first time they would take seats in an administration. "The left is making far from easy compromises here," Mr Bennett acknowledged on Sunday. According to Israeli media, the coalition agreement would allow Mr Bennett to head the government for the first two years, to be followed by Mr Lapid. It would end the long reign of Mr Netanyahu, who first rose to power 25 years ago on a wave of opposition to Shimon Peres, the architect of the Oslo Peace Accords. Despite the threat against him, it is too early to count out wily political operator Mr Netanyahu, said political scientist Jonathan Rynhold of Bar Ilan University. "It's never done until it's done, particularly because, even if they [the alliance] got by far the best hand, Bibi is the best card player by miles, you can't count him out," he said. If Mr Lapid fails to muster a coalition, and Knesset members cannot agree on another leader, Israelis will return, yet again, to the polls.