Israeli prime minister Benjamin Netanyahu appeared to be heading towards re-election early on Wednesday, as close-to-complete unofficial results showed him pulling ahead of his main competitor.
With 97% of the votes counted, Mr Netanyahu's Likud party and the rival Blue and White party had won 35 seats each.
But Mr Netanyahu was in a stronger position to form a coalition government with the anticipated support of right-wing and ultra-Orthodox Jewish parties, Likud’s natural allies.
Such a coalition could rest on 65 votes in the 120-member parliament.
With a victory, Mr Netanyahu would capture a fourth consecutive term and fifth overall, which this summer will make him Israel’s longest-ever serving leader.
Re-election will give him an important boost as he braces for the likelihood of criminal charges in a series of corruption scandals.
Both Mr Netanyahu and his challenger, former military chief Benny Gantz, leader of the rival Blue and White party, had earlier declared victory in speeches to boisterous gatherings of supporters.
A variety of results had projected Mr Gantz's Blue and White party marginally ahead of Mr Netanyahu's Likud.
But as Tuesday night went on, there were growing signs that Likud was pulling ahead.
“It’s a night of tremendous victory,” Mr Netanyahu told supporters.
“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.
In the final stretch of the campaign, Mr Netanyahu had for the first time pledged to annex parts of the occupied West Bank in a desperate bid to rally his right-wing base. Annexation would snuff out the last flicker of hope for Palestinian statehood.
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 US President Donald Trump and his success in cultivating new allies, such as China, India and Brazil.
Netanyahu's campaign tactics have also been the source of some criticism.
Speaking to ITV News, Gayil Talshir of Jerusalem's Hebrew University said: "The Netanyahu campaign was the lowest we ever saw, it was dirty. He crossed many, many lines but you see that he is the next prime minister of Israel so from that perspective the campaign worked. This is a very sad day from that perspective, to Israeli democracy."
But the corruption scandals created some voter fatigue. Along with two other former military chiefs on his ticket, Mr Gantz was able to challenge Mr 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 Mr Netanyahu with bribery, breach of trust and fraud.
Earlier in the night, with fewer of the votes counted, Blue and White still appeared to be ahead by one seat and Gantz projected optimism.
“Elections have losers and elections have winners. And we are the winners,” Mr Gantz told a victory rally shortly after midnight.
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.
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.