JERUSALEM (Reuters) - Israel’s government settled a dispute on Tuesday that had threatened its survival and prompted speculation that Prime Minister Benjamin Netanyahu was seeking a snap election to help him dodge a corruption probe.

Israeli Prime Minister Benjamin Netanyahu sits next to Israeli Education Minister Naftali Bennett during a session of the plenum of the Knesset, the Israeli Parliament, in Jerusalem, March 12, 2018. REUTERS/Ronen Zvulun

The cabinet dispute was over the framing of a bill that would extend a long-standing exemption from military service for ultra-Orthodox Jewish seminary students. For days, coalition parties had been unable to agree on the draft law.

About an hour before the preliminary vote on the bill, Netanyahu’s office said agreement had been reached and that the legislation would be finalised after April, when the Knesset returns from a break that begins this Sunday.

The coalition heads had agreed to work in accord to keep a stable government that would rule for a long period, the statement said.

“We have decided to continue together for the benefit of the citizens of Israel and for the benefit of the state of Israel,” Netanyahu told parliament.

Since the crisis began, coalition and opposition lawmakers, ministers and political analysts had been saying it was merely a pretext, and that Netanyahu actually preferred to let the government unravel, prompting an early election.

However, some of Netanyahu’s coalition partners said they did not want an early election and pushed for a solution.

The next election is not due until November 2019. A snap poll that produced a strong vote for Netanyahu despite the corruption allegations might make it harder for the attorney-general to indict him in two graft cases, as police recommend.

Recent opinion polls have shown strong backing for his right-wing Likud party, even as he faces the prospect of bribery charges in those investigations, suspicions of corruption in at least one other case, and testimony by three former aides who have turned state’s witness. Netanyahu denies any wrongdoing.

The attorney-general’s call on whether to charge Netanyahu could take months and the prime minister’s key coalition partners have so far said they will stick by him until that decision is made.

Polls in both Israel’s leading television news shows on Monday indicated that, while Netanyahu’s Likud had strong support, his majority in parliament would be razor-thin as some of his present coalition partners would lose seats.