Haggling, back channels and a midnight deal
Protesters in Tel Aviv demonstrating against the unity agreement
Benjamin Netanyahu and Shaul Mofaz's closest political advisers spent last weekend putting together teams to fight an election campaign over the coming summer - at the same time as they were fleshing out a deal to form a national-unity coalition.
While the two leaders were receiving updates on the talks - which included an agreement to postpone elections by over a year - they continued to behave as if in campaign mode, attacking each other from podiums.
Mr Mofaz, the Kadima leader, was the least interested in early elections. Only a month earlier he had finally wrested the leadership from Tzipi Livni; he wanted time to establish control of the party and build his public image.
Mr Mofaz outwardly showed confidence that he could win early elections.However, in closed meetings he admitted that a four-month campaign would be too short to close the gap.
Initial, back-channel contact was made by Lior Horev, a former strategic consultant for Kadima and, before that, Ariel Sharon's political adviser.
Mr Horev contacted Natan Eshel, a former Likud chief-of-staff who was forced to resign two months ago following allegations that he harassed an employee in the Prime Minister's Office.
The secret discussions began last week, while Mr Netanyahu was sitting shivah following his father's death. Mr Eshel arrived every day to update him.
Mr Netanyahu was initially suspicious, and Defence Minister Ehud Barak was brought in by Mr Eshel to try to convince him. The polls were predicting failure for Mr Barak's Atzmaut party and the Likud membership is against adding him to the party's list.
What finally convinced the Prime Minister was the stormy reception he received on Sunday at the Likud Central Committee, which was dominated by far-right party delegates. "Bibi wants some time to get his house in order," said a Likud member. "With this committee he will be stuck with a crazy list in the next Knesset."
The leaders of the coalition's other main parties, Avigdor Lieberman and Eli Yishai, were also brought in to agree to the expansion. Despite Mr Mofaz not being given a specific ministerial brief, there is a quiet understanding that if and when Mr Lieberman is indicted on charges of money-laundering, as is expected to happen within three months, he will resign and Mr Mofaz will become foreign minister.
On Monday, just before midnight, as the final touches were being added to the agreement, MKs were preparing to vote on dispersing the Knesset before the elections.
Suddenly, a few Kadima MKs began using delaying tactics. In a few minutes, the secret was out.
Mr Mofaz met Mr Netanyahu at the Prime Minister's residence in Balfour Street and the agreement was signed.