JERUSALEM — In another twist in a roller-coaster five days for Israeli politics, a key ally of Prime Minister Benjamin Netanyahu decided not to quit on Monday as had been expected, allowing the right-wing government to limp along and possibly avoid new elections.

Even in the best of times, Israeli politics is polarized and fractious, but the events of the past few days have been particularly fraught.

The turmoil was sparked by an intense bout of fighting with militants in the Gaza Strip last week and capped by an ultimatum from Education Minister Naftali Bennett. It is still unclear whether the government will survive even the next few days, let alone finish its term a year from now.

Although Bennett retracted his demand to become defense minister, opposition parties still planned to file a motion of no confidence in the government on Wednesday. It was anyone’s guess whether those once loyal to Netanyahu’s now-shrinking coalition would be able or even willing to fend off the move, which could lead to an early national election.

If he does make it through the next few weeks or even months, Netanyahu faces a serious challenge given his coalition’s razor-thin majority in Israel’s parliament, the Knesset: 61 seats out of 120. His government will have a tough time passing controversial legislation and could face political blackmail over more hard-line issues. 

It was the surprise resignation last week of Defense Minister Avigdor Liberman that precipitated the biggest coalition crisis Netanyahu has faced to date. 

The hawkish Liberman cited disagreements with the prime minister over how best to tackle the never-ending cycle of violence with Hamas, the Islamist group that rules Gaza. He said he had pushed for wider military action to stem rocket fire, violent protests, and the incendiary kites and balloons floated from Gaza that have caused havoc and destruction in southern Israeli communities for most of the past year.

But Netanyahu, as he indicated last week, opted for what he portrayed as a more balanced approach: focusing on the security situation while simultaneously seeking to prevent a humanitarian catastrophe for the 2 million residents of Gaza “held hostage” by Hamas. 

The flare-up of violence last week was prompted by a botched Israeli operation into Gaza. In response, militants fired more than 460 rockets and mortar shells into Israel. Israeli jets struck about 160 targets in the Palestinian enclave. Less than 48 hours after the fighting began, Netanyahu accepted a cease-fire, prompting accusations that he had capitulated to Hamas. 

Residents of southern Israel, a large portion of whom form Netanyahu’s base, have held daily protests over the government’s failure to find a viable military or diplomatic solution to the tensions with Gaza.

In his much-anticipated news conference Monday, Bennett focused on security. There had been speculation that Bennett, an ultranationalist and head of the Jewish Home party, and his deputy, Justice Minister Ayelet Shaked, would follow Liberman’s lead and resign from the government. 

For days, Bennett asked to be given the defense portfolio, insisting that he had the answers to Israel’s Gaza conundrum. If not appointed defense minister, he declared, his eight-member Knesset faction would quit the government, causing it to collapse.

But by Monday, he had dropped his demand, saying he would stay on as education minister to help in the “great mission of making Israel win again.”

“I know I may pay a political price. It is not the end of the world. You win some, you lose some,” he said. Explaining his backtracking, Bennett referred to calls among his supporters not to bring down the government, considered the most right-wing in Israel’s history.

Netanyahu’s adroit orchestration of the political turmoil to his own benefit, however, also may have played a role in Bennett’s reversal.

On Sunday night, after a weekend of speculation that an election was on the way, Netanyahu called an impromptu news conference. The Israeli leader not only invoked his past and present sacrifices for the country — a move that drew comparisons to Netanyahu’s own hero, former British prime minister Winston Churchill — but also alluded to the security threats Israel faces. 

Announcing that he would keep the defense portfolio for himself, Netanyahu dared Bennett and other coalition partners to bring down his government in the face of the ongoing security concerns and noted that previous right-wing Israeli governments were often succeeded by more left-leaning ones.

On Monday morning, a statement from his office said Netanyahu had taken over the Defense Ministry, meeting with the army’s current chief of staff, Gadi Eisenkot, and the incoming head, Aviv Kochavi. 

“As I said last night, we are in a battle that has not yet ended. In such a sensitive period of security, it is irresponsible to topple the government,” Netanyahu said. 

Yehuda Ben Meir, a senior associate at the Institute for National Security Studies, said it was “clear Netanyahu wants to push off elections as much as he can.”

With important dates coming up, such as the American Israel Public Affairs Committee conference in March, Israel’s national days in early May and even the forthcoming Eurovision Song Contest in Tel Aviv, there will be many opportunities for Netanyahu to regain some of his lost support.

“Netanyahu took a huge risk and a hit to his popularity agreeing to the cease-fire,” said Emmanuel Navon, senior fellow at the Jerusalem-based Kohelet Policy Forum and a member of the Likud Central Committee. 

“Netanyahu has always presented himself as Mr. Security. It would be suicidal to go to the polls now after an extremely unpopular decision and a humiliating cease-fire with Hamas,” Navon said. “He just wants to push off elections as much as he can.”