JERUSALEM -- Israel's president on Saturday granted Prime Minister Benjamin Netanyahu a two-week extension to form a governing coalition, a task complicated by mathematics and chemistry.
Mr. Netanyahu, Israeli analysts say, finds himself in a bind as he tries to solve the coalition puzzle. His options have been curtailed by an unexpected alliance between two rising stars bent on preventing his longstanding ultra-Orthodox allies from joining the next government.
Yair Lapid, a former television host, stunned the political establishment when his centrist party, Yesh Atid, placed second in the January elections. It won 19 seats in the 120-seat Parliament, positioning Mr. Lapid as a power broker. Adding to his bargaining power, Mr. Lapid has forged an unlikely negotiating alliance with Naftali Bennett's right-wing Jewish Home, the winner of 12 seats.
Mr. Netanyahu, whose rightist Likud-Beiteinu faction has 31 seats, needs at least one of those two parties -- plus some of his traditional partners -- to be able to form a coalition with a majority of 61 or more, and he might need both. But he would also like to maintain his long partnership with the ultra-Orthodox.
So far, Mr. Lapid and Mr. Bennett have pledged to go into the coalition together or not at all. "I do not recall such a strong alliance between two such different parties," said Gadi Wolfsfeld, a professor of political communication at the Interdisciplinary Center in Herzliya. "These two leaders seem to have chemistry, and the one thing they share is a desire for a government without the ultra-Orthodox. Wow!"
The pair's argument for not including the ultra-Orthodox parties hinges on their promises to end exemptions from compulsory military or civilian national service for ultra-Orthodox young men engaged in Torah studies. The demand for a more equal sharing of the burden was popular among the middle-class voters championed by Mr. Lapid and in Mr. Bennett's camp. But Likud members say that Mr. Lapid's opposition to including the ultra-Orthodox goes beyond that.
After talks with Yesh Atid and Jewish Home on Thursday and Friday, David Shimron, a lawyer representing Likud-Beiteinu, told reporters that Mr. Netanyahu wanted to form as broad a coalition as possible but that Mr. Lapid would rule out the ultra-Orthodox as coalition partners even if the ultra-Orthodox "were drafted at the age of 14."
"A whole public is being boycotted," Mr. Shimron added. "We don't accept boycotts, and we'll have to see how we move forward to form the government under these circumstances."
Shas, the largest ultra-Orthodox party, representing Sephardic Jews, has been a mainstay of many governments led by the right and the left since it was founded in 1984. It was last excluded, from Ariel Sharon's government in 2003, on the insistence of the staunchly antireligious Shinui Party, which was led by Mr. Lapid's father, Yosef.
A brief honeymoon period between Mr. Netanyahu and Yair Lapid after the elections quickly soured after Mr. Lapid spoke about his intention to replace Mr. Netanyahu as prime minister, possibly within 18 months.
So far, Mr. Netanyahu has found only one new coalition partner: the small Hatnua Party, led by Tzipi Livni, a former foreign minister and a longtime critic of Mr. Netanyahu's handling of the Palestinian conflict. She has been promised the post of justice minister and a leading role in any talks with the Palestinians.
But a government without Shas will leave Mr. Netanyahu more vulnerable; his conservative Likud Party emerged weakened from the elections, with Yesh Atid and Jewish Home each holding the power to make or break any potential coalition.
Mr. Netanyahu's decision to run on a joint ticket with the ultranationalist Yisrael Beiteinu Party of his former foreign minister, Avigdor Lieberman, "deterred voters on all fronts -- centrists, Sephardim, national religious," said Abraham Diskin, a political scientist at the Hebrew University of Jerusalem and the Interdisciplinary Center. "These are the results. Mr. Netanyahu would be much stronger with Shas in the coalition. His maneuvering capability has definitely been limited."
But political experts also note that coalition deals in Israel are rarely written in stone. Shas, despite its objections, could join Mr. Netanyahu's next coalition later, after new legislation on the military obligations of the ultra-Orthodox has been resolved.
Most Shas voters already serve in the army, said Asher Cohen of Bar Ilan University, adding: "Shas will always want to be in the coalition. There is no historical basis to believe that it won't."
With an extension, Mr. Netanyahu will have until mid-March to forge a new government. If he fails, President Shimon Peres could ask another party leader to take on the task.
"Netanyahu needs to form a coalition and get through the vote of confidence in Parliament," said Gideon Rahat of Hebrew University. "After that, he can always change the makeup of the coalition. The day after the vote of confidence, Lapid could leave and Shas could join. I'm not getting excited."
As a politician, Mr. Rahat said, Mr. Netanyahu "is no magician."
"But the state of politics in Israel is so bad," he added, "that even someone who is not especially successful can succeed."
This article originally appeared in The New York Times.