It was the ultimate humiliation. Mr Shimon Peres, the Nobel laureate and former prime minister, was running for the largely ceremonial office of state president, vying with a mild-mannered bit-player from the Likud, the opposition party that had never succeeded in getting its presidential candidate elected. Every pundit confidently predicted a Peres victory. Every pundit was wrong.
When the 120 members of the Israeli parliament cast their votes in secret ballot yesterday, a first round of voting saw 60 supporting the Iranian-born ex-tourism minister, Mr Moshe Katsav, and only 57 plumping for Mr Peres.
Since an absolute majority was required - 61 of the 120 votes - it went to a second round; this time Mr Katsav got 63 votes to Mr Peres's 57.
The champion of the Oslo peace process with the Palestinians, the father of Israel's nuclear weapons programme, the politician who has left his imprint on almost every phase of modern Israel's development, had been defeated by a relative nonentity. The statesman whose international connections are legendary, but who had failed in five attempts to win a general election outright, and became prime minister only in unity governments or when succeeding the assassinated Yitzhak Rabin five years ago, had failed again. The reluctant beneficiary of far too much bitter experience, Mr Peres (77) was gracious in defeat, congratulating Mr Katsav (55) before exiting the Knesset building. Mr Katsav, too, was gentle in victory, praising his opponent for the conduct of what was an entirely well-mannered campaign to succeed Mr Ezer Weizman, the state's seventh president, who was forced to step down early because of financial misdealings.
The key architects of Mr Peres's defeat, as of so much that occurs these days in Israeli politics, were the 17 men of the ultra-Orthodox Shas party, many of whom had been expected to support him, few of whom did. Mr Peres was always thoroughly respectful of the ultra-Orthodox. But Mr Katsav, although a Likud member, is "one of them" - a Sephardi Jew, a member of the immigrant "underclass" that has long claimed, with some justification, to have suffered discrimination in the early years of the state at the hands of the Ashkenazi establishment of European-born Jews like Mr Peres.
But it was not Shas alone that did for Mr Peres. Rumour has it several members of his own party voted against him. Not the Prime Minister, Mr Ehud Barak, however. "My heart," he said when the result was announced, "goes out to Shimon."
Perhaps uniquely in Israeli politics, Mr Katsav, an opponent of the Oslo process but no extremist, claims to have no real enemies in the Knesset . . . and he may be right. The first Likud president was also the first student from his working class town of Kiryat Malachi to get a place at Jerusalem's Hebrew University, and was the country's youngest mayor, at 24.
Almost self-effacing in character, he pledged yesterday to try to "reduce the tensions in Israeli society". He has his work cut out.