If Benjamin Netanyahu was going to lose one Israeli election in a big way, it may have been this one. Or at least that is how it appeared to some onlookers.

The prime minister was clearly on a downward trajectory. After embarrassingly losing allies and failing to form a government after last April’s election, the 70-year-old rightwing leader suffered a humiliating result in a repeat vote in September.

He managed to limp on by stymying his opponent, Benny Gantz, and forcing an unprecedented third election, but the situation deteriorated further: in November, Netanyahu was indicted for bribery, fraud and breach of trust in three major criminal cases. In December, he had to fend off an internal leadership challenge.

Adding to his woes, the timing of Monday’s election – held just two weeks before a scheduled court appearance in Jerusalem – could not have been worse.

Yet as the votes were being counted on Tuesday, it seemed Netanyahu, who denies all the charges, had somehow regained his swagger. While it remains unclear if he can form a government, or if the country is doomed to remain in political stasis, his ruling Likud party appears to be on track to win a significant number of seats and more than any other faction.

Writing in the often pro-Netanyahu newspaper, Israel Hayom, commentator Mati Tuchfeld said the result was a comeback unseen in Israeli politics.

He wrote: “Remember, this isn’t some shiny new candidate who managed to attract a large following, but the longest-serving prime minister in Israeli history who has reinvented himself.”

Blame may inevitably fall on his opponent, Gantz, who never truly differentiated himself ideologically. The former chief of the army largely agrees with Netanyahu on many of the key issues, including the continued occupation of the Palestinian territories and allying with other nationalist rulers such as Donald Trump.

Instead, Gantz ran his campaign on notions of personal honesty and integrity. He hoped Israelis would see him as a clean-cut alternative to Netanyahu. But even if they did, it did not help him.

That leaves perhaps two clear explanations for the result – voters either do not believe the corruption allegations, or they do not care. In this respect, there are parallels with some of Trump’s supporters in the US, who either refuse to believe or are happy to downplay criticism of his conduct.

People stand in front of a TV screen displaying an exit poll in Tel Aviv after voting closed. Photograph: Menahem Kahana/AFP via Getty Images

After midnight on Tuesday, at the ruling Likud party’s election event in Tel Aviv, the atmosphere was much more upbeat than the previous two rounds. Yuli Edelstein, the speaker of the Knesset, Israel’s parliament, and Likud politician, walked confidently with a small entourage through the cheering crowds.

Quickly asked about why the corruption cases appeared not to have had a bigger impact, he summed it up: “The people knew all the facts and figures, and this was their decision and their vote.”

Earlier on election day, a grocer in Jerusalem, Ilana Benyamin, said the accusations of corruption did not phase her. She repeated a widely held local belief that Netanyahu’s 10-year run in power has made Israelis safer and richer, which she said was more important. “I don’t mind if he eats takeaway food in boxes covered with diamonds. Look at what is happening around us,” she said.

As in previous campaigns, Netanyahu claimed only he could score big diplomatic wins from foreign leaders such as Trump, who agreed to long-taboo Israeli demands for permanent control of parts of the occupied territories. He also energised his hardline nationalist base by demonising citizens from Israel’s Arab minority and repeatedly promising future land grabs from Palestinians.

So why didn’t Netanyahu also win in the last election? Campaign officials said the strategy this time was to turn a negative campaign – one in which the prime minister was warning of immediate demise – into a positive one.

Rather than attempting to scare people into voting, which may have resigned them to a loss, Likud spread the message that victory was within their reach – if they turned out to vote.

The campaign also found out that several tens of thousands of their supporters had not voted in the previous elections. They then went out to find them, one by one.

Ravit Hecht, a columnist for the left-leaning Haaretz newspaper, said Netanyahu had run a “venomous campaign” against Gantz by delving into his personal life. Vitally, she said, the leader persuaded voters that only he could end the painful political chaos by winning, even if it had a deeper cost for the country.

“It’s worth mulling for a moment the choice that was made,” she wrote, “considering the admiration of Netanyahu’s cruelty, the worshipping of his dictatorial aggressiveness and the enthusiastic support for his campaign that included unbridled racism, lies, mudslinging and a descent into a moral abyss.”