Likud party supporters cheer at the party's campaign headquarters after polls for Israel's general elections closed in Tel Aviv, Israel, Wednesday, April 10, 2019. (AP Photo/Ariel Schalit)

JERUSALEM (AP) — Benjamin Netanyahu appeared to be headed toward a historic fifth term as Israel's prime minister on Wednesday, with near-final election results giving his right-wing Likud and its traditional Jewish ultra-Orthodox and nationalist allies a solid majority in parliament.

Here's a look at what comes next:

FINAL RESULTS

There are still some votes to be counted as ballots of soldiers, diplomats, prisoners, hospital patients and some others who vote in unusual circumstances take a bit longer to tally. The full picture usually emerges within a day, in this case Thursday, but since a couple of parties are teetering along the electoral threshold and their political survival depends on every vote, legal appeals seem likely. That could extend the process, with no specific guidelines on how long this could take. The Central Elections Committee releases final results eight days after an election — meaning April 17.

___

THE PRESIDENT

Once the full picture is clear, attention shifts to President Reuven Rivlin. Though his responsibilities are mostly ceremonial, the president is charged with choosing a candidate for prime minister after consulting with party leaders and determining who has the best chance of putting together a stable majority coalition. That responsibility is usually given to the head of the largest party, but not necessarily.

Rivlin will meet with the heads of all parties and hear their recommendation in the coming days. He will then task the leading candidate, who will have 42 days to form a coalition government. If he fails, the president can turn to another candidate and give him 28 days to form an alternative coalition. If that too fails, which has never happened, new elections are called.

___

RULING COALITION

Israeli democracy operates on a parliamentary system of proportional-representation in which the government needs a majority to rule. Since no party has ever earned more than 61 of the 120 seats in the Knesset, a coalition is required.

Netanyahu's Likud and Benny Gantz's Blue and White party were deadlocked on Wednesday at 35 seats in the 120-seat parliament. But even if Likud eventually drops below, Netanyahu will likely still get the nod given the size of his bloc, which currently holds a 65-55 advantage. Likud has traditionally had an alliance with the ultra-Orthodox Shas and United Torah Judaism parties, and the pro-settler Jewish Home party that this time aligned with the anti-Arab Jewish Power faction. Though nationalist ministers Naftali Bennett and Ayelet Shaked of the newly formed "New Right" party look to have come up short of the electoral threshold, Netanyahu still has enough other right-wing and religious parties at his disposal.

___

WHAT HAPPENS AFTER THAT?

The ceremonial opening of the 21st Knesset, or parliament, will take place on April 29 or 30. This ceremony usually happens two weeks after the election, but due to the Passover holiday, it will be delayed this year by a week. By the end of May, the candidate tasked with building a coalition is required to sign agreements with his partners to present the new government. By early June, the new government is sworn in.

___

NETANYAHU'S LEGAL TIMETABLE

Israel's attorney general has recommended indicting Netanyahu on bribery and breach of trust charges in three separate cases, and Netanyahu's legal situation will hover over his next term in office. Attorney General Attorney General Avichai Mandelblit will only decide on indicting Netanyahu after a legally mandated hearing. Legal experts expect at least some charges to be filed. Mandelblit said he will send detailed material to Netanyahu's lawyers after the election in advance of the hearing, though it was not clear exactly when this would happen.

Once the lawyers have all the paperwork, they usually get a month to prepare. But since the various Netanyahu cases are complicated it may take longer, with the hearing pushed back to later in the summer. Though not legally required to resign if formally charged, Netanyahu may be pushed out by some coalition partners who will refuse to keep serving under him in such a circumstance.

Israel's Prime Minister Benjamin Netanyahu smiles after voting during Israel's parliamentary elections in Jerusalem, Tuesday, April 9, 2019 (AP Photo/Ariel Schalit, Pool)
Israel's Prime Minister Benjamin Netanyahu waves to his supporters after polls for Israel's general elections closed in Tel Aviv, Israel, Wednesday, April 10, 2019. (AP Photo/Ariel Schalit)