A betting man would have demanded long odds a year ago on Sri Lanka completing a peaceful transition of power after years of international isolation under the authoritarian leader who brought a bloody end to the country's civil war.
But in Monday's parliamentary elections, the bespectacled Maithripala Sirisena, who came from nowhere to win the presidency in January, confounded the doubters, thwarting a comeback by predecessor Mahinda Rajapaksa, a civil war hero to many Sri Lankans but war criminal to others.
Rajapaksa, who changed the constitution in a bid to retain power in the Indian Ocean island of 21 million, had set his sights on becoming premier of a government led by his Sri Lanka Freedom Party (SLFP).
But the unassuming Sirisena, who started out as a "positive fluke" selected by the broad-based civic movement that campaigned to end the Rajapaksa era, has surprised even close aides with a Machiavellian ability to win with a weak hand.
It was only on election day that Sirisena, who had succeeded Rajapaksa as SLFP leader, purged Rajapaksa loyalists who controlled the party's executive and for months had refused to bend to his will.
"Civilised politics is a blend," a senior Sirisena adviser told Reuters. "If you don't use certain high-handed tactics, you cannot survive."
Armed with a strong mandate for a coalition headed by Ranil Wickremesinghe and his United National Party (UNP), Sirisena should now be able to push through reforms to open up government and simplify Sri Lanka's complex election rules.
Minority Tamils and Muslims have rallied behind the coalition.
Defeat for Rajapaksa will keep Sri Lanka on a non-aligned foreign policy course and loosen its ties with China, which during his rule pumped in billions of dollars to turn the island into a maritime outpost.
As recently as last month, warning lights were flashing that Sirisena lacked the nerve to stop Rajapaksa capitalising on the parliamentary vote, which the 63-year-old president had called early to seek a stronger mandate for reform.
"There was a lot of worry that Mahinda was an unstoppable force," said Alan Keenan, a Sri Lanka analyst at the International Crisis Group.
But, in a July 14 speech, Sirisena vowed not to name Rajapaksa prime minister, even if the SLFP won. "That speech by Sirisena was able to turn the tide," said Keenan.
Although Wickremesinghe's UNP won by a margin of only 3 percent, Sirisena's rejection of Rajapaksa may have been enough to sway the result.
"If the president is saying he is not going to name your guy prime minister, why would you go out and vote?" said one Western diplomat.
Sirisena's presidency began inauspiciously; having walked out of Rajapaksa's government to run against him, he was forced into 'cohabiting' with a UNP minority government that controlled just a third of seats in parliament.
He managed to secure the passage of a constitutional amendment to weaken the powers of an executive presidency he believes enabled the excesses of the Rajapaksa era, but other reforms stalled. Corruption probes against two of Rajapaksa's brothers, who together had controlled 70 percent of the budget, went nowhere.
But, all the while, Sirisena was seeking to broaden support at home and abroad, courting U.S. Secretary of State John Kerry and British Prime Minister David Cameron.
"Sirisena went out there and built those relationships," another diplomat said. "He took Sri Lanka out of isolation."
That should set the stage for a discussion on how Sri Lanka can come to terms with the legacy of its 26-year civil war, which ended when Rajapaksa crushed Tamil insurgents in 2009 in an offensive the United Nations estimates killed 40,000.
A U.N. war crimes report is due ahead of talks in Geneva next month where Sri Lanka should commit to prosecuting perpetrators and establish some form of truth and reconciliation process under international scrutiny.
While these talks will be difficult under Sirisena, who has made tentative steps towards reconciliation, they would have been unthinkable before. In his campaign, Rajapaksa urged voters to oppose those who "would divide this country and take us to court in Geneva".
Rajapaksa and his inner circle may have more to fear from domestic prosecution in a series of criminal probes that sources say are likely to be stepped up. He and his family deny any wrongdoing.
Sirisena's political machinations may, however, test the SLFP to breaking point. Rajapaksa, 69, has ruled out retirement, increasing the risk of a more abrupt political realignment, or even a party split.
"Some MPs will recognise that the Rajapaksas are running helter-skelter under corruption allegations," said a senior government minister. "They will realise where the power is - with Maithripala Sirisena."