Israeli Prime Minister Benjamin Netanyahu appeared to be headed toward re-election early Wednesday, as exit polls and partial results showed him edging ahead of his main competitor in a tight race that was seen as a referendum on the long-serving leader.
Both Netanyahu and former military chief Benny Gantz, leader of the rival Blue and White party, declared victory in speeches to boisterous gatherings of supporters. But as the night went on, there were growing signs that Netanyahu's Likud was pulling ahead.
With a victory, Netanyahu would capture a fourth consecutive term and fifth overall, which this summer will make him Israel's longest-ever serving leader. Perhaps more crucially, re-election will give him an important boost as he braces for the likelihood of criminal charges in a series of corruption scandals.
The 69-year-old prime minister has been the dominant force in Israeli politics for the past two decades and its face to the world. His campaign has focused heavily on his friendship with President Donald Trump and his success in cultivating new allies, such as China, India and Brazil.
But the corruption scandals created some voter fatigue. Along with two other former military chiefs on his ticket, Gantz was able to challenge Netanyahu on security issues, normally the prime minister's strong suit, while also taking aim at the prime minister's alleged ethical lapses.
Israel's attorney general has recommended charging Netanyahu with bribery, breach of trust and fraud. The telegenic Gantz, who has been vague on key policy fronts, has presented himself as a clean, scandal-free alternative to Netanyahu.
Initial exit poll results by Israel's main TV stations showed the two parties far ahead of all of the other competitors in the race and indicated that Blue and White would emerge as the largest party.
"Elections have losers and elections have winners. And we are the winners," Gantz told a victory rally shortly after midnight.
He vowed to change the tone of Israel's divisive political system and "be the prime minister of everyone, not just the ones who voted for me."
But as results trickled in throughout the night, the Likud appeared to be gaining strength. With over 90 percent of the votes counted, Likud held a narrow lead over Blue and White, with Netanyahu's parties expected to take 37 seats — one more than Gantz.
Though both parties were well short of a majority in the 120-seat parliament, the polls showed Likud and its religious and nationalist allies controlling a solid majority.
"It's a night of tremendous victory," Netanyahu told his own victory rally. "I was very moved that the nation of Israel once again entrusted me for the fifth time, and with an even greater trust."
He said he had already begun talking to fellow right wing and religious parties about forming a new coalition.
"I want to make it clear, it will be a right-wing government, but I intend to be the prime minister of all Israeli citizens, right or left, Jews and non-Jews alike," he said.
The message was a sharp contrast from his campaign theme in which he accused Gantz of conspiring with Arab parties to topple him. Arab leaders accused Netanyahu of demonizing the country's Arab community, which is about 20 percent of the population.
His attacks on the Arab sector fueled calls for a boycott, and appeared to result in relatively low turnout by Arab voters. Israel's central elections commission banned parties from bringing cameras into polling stations after Likud party activists were caught with hidden cameras in Arab towns.
The final results are subject to change. Some 40 parties took part in the election, and only those that receive at least 3.25% of the votes make it into parliament.
The final results will depend on the performance of several small parties, including the Arab Balad party and the ultranationalist "New Right," that were on the cusp of entering parliament. If any of them fail to cross the threshold, the makeup of the next coalition could be dramatically affected.
Yohanan Plesner, a former lawmaker and head of the nonpartisan Israel Democracy Institute, called the close and conflicting exit polls "an unprecedented situation."
"We've had elections before where he didn't know the results but here it is even messier," he said.
Once the final results come in, attention will turn to President Reuven Rivlin. The president, whose responsibilities are mostly ceremonial, is charged with choosing a prime minister after consulting with party leaders and determining who has the best chance of putting together a majority coalition. That responsibility is usually given to the head of the largest party.
The election included several other surprises. Exit polls all projected the iconic Labor party, which ruled the country for its first 30 years, tumbling to single digits in the parliament.
Zehut, an iconoclastic party that combined an ultranationalist ideology with libertarian economic positions and calls for the legalization of marijuana, had appeared poised to emerge as the Cinderella story of the election. But the exit polls showed it falling short and not entering parliament.
If Netanyahu is re-elected, attention will quickly focus on his legal woes. The attorney general has recommended a series of criminal charges against the prime minister, but will only make a decision on indicting him after a legally mandated hearing. Legal experts expect at least some charges to be filed.
Netanyahu will likely focus his efforts on getting guarantees from his coalition partners to continue to back him if he is indicted, and perhaps find a way to grant him immunity from prosecution.
Netanyahu has denied any wrongdoing and claimed he is the victim of a witch hunt.
In order to appeal to his religious and ultranationalist parties, Netanyahu veered sharply right on the campaign trail with attacks on Arab politicians, the media and the judiciary. He also pledged to annex West Bank settlements, a step that could snuff out any remaining hopes for a two-state solution with the Palestinians.
Palestinian official Saeb Erekat lamented that the Israelis voted to maintain "the status quo."
"They want their occupation to be endless," he said.
AP journalists Ilan Ben Zion and Isabel DeBre contributed to this story.