Jerusalem CNN  — 

Benjamin Netanyahu was on course to secure a record fifth term as Israeli Prime Minister after his main election rival conceded defeat on Wednesday evening.

After a dramatic finish to a tightly-fought race, former army chief Benny Gantz accepted that Netanyahu had won. “We are all democratic, we all accept the decision of the nation,” Gantz said.

With more than 97% of the vote counted, according to Israeli media, a bloc led by Netanyahu’s Likud party would secure 65 seats in the 120-strong Knesset. A center-left bloc led by Gantz’s Blue and White party, supported by the Arab parties, would only muster 55 seats.

Likud supporters celebrate as Prime Minister Benjamin Netanyahu waves to them at its headquarters in Tel Aviv.

Likud tied with Blue and White, gaining 35 seats each. But Netanyahu’s path back to power is clearer, combining seats won by two ultra-orthodox religious parties, which both polled well, with those of smaller right-wing groups.

Netanyahu claimed victory Tuesday night. “The right-wing bloc led by the Likud won a clear victory. I thank the citizens of Israel for the trust. I will start forming a right-wing government with our natural partners as soon as tonight,” Netanyahu said.

Having all but secured his cherished fifth term, Netanyahu will become Israel’s longest-serving leader in the summer, overtaking David Ben-Gurion, the country’s founder. The votes of diplomats abroad and soldiers are yet to be counted.

Israel’s President, Reuven Rivlin, will decide who will form the next government after consultations with the heads of the political parties that secured enough seats in the Knesset. The President is likely to announce his decision in about a week.

On Wednesday, US President Donald Trump congratulate on Twitter, “Spoke to Bibi @Netanyahu to congratulate him on a great and hard-fought win. The United States is with him and the People of Israel all the way!”

Israeli Prime Minister Benjamin Netanyahu, accompanied by his wife Sara, greets supporters.

In the final days of the campaign, Netanyahu veered sharply to the right, pledging to annex West Bank settlements if re-elected, and warning his voter base that the end of his strong right-wing government would signal the beginning of a weak left-wing government.

Netanyahu fought the election in the face of looming indictments for bribery and breach of trust offenses, which he sought to portray as a witch-hunt led by left-wing elites and fed by the media. The date for a final hearing in the case is yet to be set.

At first, Netanyahu faced a diverse array of opponents. But then three former army chiefs come together with a TV news anchor-turned-politician to create the Blue and White party, named after the colors of the Israeli flag. Led by Gantz, a former head of the army under Netanyahu, Blue and White’s polling numbers surged, and the election quickly became a two-horse race.

Blue and White party leader Benny Gantz addresses his supporters after Israeli general elections polls closed.

Netanyahu – known to supporters and detractors alike as “Bibi” – focused on burnishing his status as a global player with close ties to both the President of the United States and the President of Russia.

In a visit to Washington made by Netanyahu during the campaign, Donald Trump signed a proclamation recognizing Israeli sovereignty over the Golan Heights, in defiance of the overwhelming international consensus. And in the election’s closing days, on a visit to Moscow, Netanyahu was able to personally thank Vladimir Putin for Russia’s key role in locating the body of an Israeli soldier who had been missing in Lebanon for nearly 37 years.

With his victory all but certain, attention will now turn to the corruption case. The Supreme Court will rule on whether Netanyahu can continue in office if he is charged.

For his part, Netanyahu has denied any wrongdoing.