With less than two hours to go before the final deadline for forming a government, Likud and Habayit Hayehudi negotiating teams finalised an agreement which allowed Benjamin Netanyahu to inform President Reuven Rivlin that he had succeeded in fulfilling his mandate.
It took six long weeks from the election in March, and despite winning by a large margin, Mr Netanyahu's fourth government is currently supported by only 61 Knesset members, a majority of one.
By the end of last week, Mr Netanyahu seemed on course to sign agreements with five coalition partners which, in addition to his Likud, would have given his government the backing of 67 MKs.
But the surprise announcement on Monday by - now former - foreign minister Avigdor Lieberman that his party, Yisrael Beiteinu, would not be joining the government, blew a big hole in the plan.
Mr Lieberman claimed that he was choosing "principles over seats" and that he was resigning because the new government was "not national" enough and not sufficiently committed to building in the settlements and East Jerusalem.
The new government will find it almost impossible to legislate serious reforms
However it seems more likely that he was choosing opposition because his political influence is on the wane. He has fallen out with the prime minister and in the election Yisrael Beiteinu won only six seats.
By that point there were agreements signed with three of the parties - Kulanu, Shas and United Torah Judaism - but with only two days left, a deal had yet to be signed with Habayit's leader Naftali Bennett. The two parties had already agreed that Mr Bennett would become education minister and that the party would receive control of the agriculture and culture ministries. Then he took the prime minister down to the wire and demanded the justice portfolio in return for his party's support.
Mr Netanyahu had no choice but to relent. Now, Ayelet Shaked, Mr Bennett's closest political ally, is to be the justice minister in the new government. She will also chair the powerful ministerial legislation committee and the judicial appointments commission. A vocal critic of Israel's Supreme Court, Ms Shaked will lead an attempt by the right-wing and religious parties to limit the powers of the Supreme Court.
With only 61 seats, the new government will find it almost impossible to legislate serious reforms, and without a foreign minister - for now, Mr Netanyahu is keeping the portfolio for himself - it is not planning any major diplomatic initiatives.
Likud insiders expect attempts to bring the Labour Party into a national-unity government to continue over the next few weeks. In such a case, party leader Yitzhak Herzog would be the new foreign minister and Habayit Hayehudi would most likely leave the coalition. Despite back-channel negotiations between Mr Herzog and Mr Netanyahu over the last few weeks, an agreement was not reached, due in part to Mr Herzog's refusal to enter a coalition without his election partner Tzipi Livni, and his demand to serve as prime minister for at least a year of the new government's term.