Six weeks of coalition talks drew toward a successful conclusion Wednesday evening, when the Likud finally conceded the Education Ministry to Yesh Atid’s Yair Lapid, and Lapid reportedly accepted the other terms of Likud’s compromise offer.

Prime Minister Benjamin Netanyahu was set to meet with Lapid, Jewish Home leader Naftali Bennett and former foreign minister Avigdor Liberman to confirm the terms.

“This government will be good for Israel,” Bennett said Wednesday night.

The necessary legal documents were to be drawn up and signed Thursday, leaving Netanyahu free to formally inform President Shimon Peres on Saturday night — the final day of the six weeks allocated to him — that he has mustered a Knesset majority. The coalition will comprise four parties: Likud-Beytenu (31 seats), Yesh Atid (19), Jewish Home (12) and Hatnua (6), for a total of 68 members in the 120-seat Knesset.

The outgoing government is set to hold a final meeting on Sunday, and the new government will be sworn in Monday — some 48 hours before the scheduled arrival of Barack Obama on his first presidential visit.

In return for having his No. 2, Rabbi Shai Piron, appointed education minister, Lapid agreed to give up on some of his other demands, including control of the Interior Ministry, his opposition to Hatnua having two ministers, and his objection to the Likud gaining an extra deputy minister, Channel 2 reported.

Gideon Sa’ar, Likud’s serving education minister, only learned that he would likely be losing his job from the TV reports, Channel 2 said, adding that he was now set to be made minister of the interior.

Along with Piron at education, Lapid himself is set to serve as finance minister, and Yesh Atid will likely have three other ministers in a cabinet of 21-22 members. Bennett will be minister of economics and trade, and his Jewish Home party will have two more ministers, one of whom is likely to be Uri Ariel at Housing.

Bennett reportedly told Lapid that if he didn’t accept Netanyahu’s compromise offer, Jewish Home would sign a coalition deal without Yesh Atid.

Netanyahu will hold the Foreign Ministry, to hand over to former foreign minister Liberman should he beat the fraud and breach of trust charges that forced his resignation in December. Likud’s former IDF chief of General Staff Moshe Ya’alon is set to succeed Ehud Barak as minister of defense. Likud-Beytenu will hold 11 ministries in all.

Tzipi Livni, who signed a coalition deal with Netanyahu last month, is to serve as justice minister, with her Hatnua party colleague Amir Peretz at environmental affairs.

There will be seven or eight deputy ministers, one of them, from Likud, at education.

Bennett, ending talks Wednesday afternoon with Lapid, had said he was confident that the two parties would yet resolve their differences with Netanyahu’s Likud-Beytenu and form a coalition. “There’ll be a government. I’m optimistic,” Bennett said, before heading off for further consultations with Likud representatives.

Bennett, who has emerged as the mediator between Netanyahu and Lapid in the final days of the coalition countdown, was speaking hours after Netanyahu issued an ultimatum to Lapid: either sign a deal to join the coalition, or the Likud will start negotiating with the ultra-Orthodox parties, Shas and United Torah Judaism.

“If there is no breakthrough in coalition negotiations with Yair Lapid in the next few hours, and he doesn’t back down from his excessive demands, the prime minister will initiate talks with the Haredi parties,” a senior Likud official said Wednesday morning.

It was not clear how potent the Likud threat was, since even with both ultra-Orthodox parties on his side, Netanyahu could not muster a Knesset majority without Bennett. And Bennett had been resolute that he would not join a coalition without Lapid.

Moreover, the ultra-Orthodox parties, having been spurned by Netanyahu in the past few weeks of talks, would likely not have allied with him cheaply, and would not easily accept the idea of mandatory national service for their young males — a demand that has been emphatically advanced by Lapid and Bennett, and that has wide public support.

Still, Shas’s Eli Yishai was reported in the ultra-Orthodox media to have been consulting with the party’s spiritual leader Rabbi Ovadia Yosef Wednesday over the possibility of joining the coalition.

Earlier this week, Lapid rejected Likud’s suggested power-sharing deal for the education portfolio — the key obstacle to a coalition deal. Likud was determined to see Sa’ar maintain his position, while Yesh Atid insisted the post go to Piron.

“The coalition crisis that we are witnessing now is not merely a battle over ministerial portfolios. Yesh Atid’s insistence on receiving the Education Ministry stems from the fact that the path toward changing Israeli society lies there,” Yesh Atid said in a statement. “Yesh Atid asked for the public’s trust in order to battle not just for [a reduction in] the size of the government and equal share of the burden, but also for education and Israeli society’s future. Yair Lapid will not back down on his principles, even it means he has to sit in the opposition.”

“Education is at our core,” Yesh Atid MK Meir Cohen told Israel Radio. “It’s up to the prime minister to decide whether to give it to us or face new elections.”

The first-time MK said Yesh Atid wanted control of the Education Ministry because of its importance in shaping Israeli society, and charged that Likud only cared about the post because it ensured the party could maintain its influence over the ultra-Orthodox public by controlling the purse strings that fund Haredi educational institutions.

“We plan to introduce greater transparency to the budget, which discriminates between sectors [of Israeli society],” said Cohen, himself a former school principal.

Shortly after reports of Likud’s ultimatum began to circulate, Bennett posted a message on Facebook reading: “My friends in the Likud: forget about it. This is not the way. There are gaps. We need to talk and compromise, all of us, until a new government is formed. There is a state to worry about.”

Netanyahu met in secret with Bennett for several hours Tuesday night. During the meeting, Bennett repeatedly called Lapid in an effort to bridge the differences between the two leaders, but with no success.

Likud, Yesh Atid and Jewish Home were also battling over control of the powerful Knesset Finance Committee, with Jewish Home reportedly winning the battle to chair the panel under the final compromise.

Likud-Beytenu, Yesh Atid and Jewish Home agreed on Monday to shrink the Cabinet to 20 ministers plus the prime minister, down from 30 in the last government. The issue had been a central demand of the Yesh Atid party, which had wanted a cap of 18 ministers.

They also reportedly agreed to raise the threshold for Knesset representation from 2% to 4% from the next elections, a move that could dramatically reduce the number of parties making it into parliament.

The reduction in the size of the Cabinet marks a significant achievement for Lapid, who argued that a lean government would set the right example for Israel as it faces budget cuts in a challenging economic environment.

The smaller cabinet will complicate Netanyahu’s difficulties within his own Likud, where too many outgoing ministers and rising political players are competing for too few cabinet seats. Danny Danon and Tzipi Hotovely, two younger politicians who did well in the Likud party primaries, have been publicly advancing their own claims, but are seen as unlikely to make it into the cabinet. And there may simply not be enough jobs for all outgoing Likud ministers such as Silvan Shalom, Yisrael Katz, Gilad Erdan, Yuval Steinitz and Limor Livnat.

Media reports Wednesday evening suggested bitter internal fighting in the Likud over the relative paucity of the party’s ministerial options.