NEW DELHI: After a decade in power, Sri Lankan President Mahinda Rajapaksa -- who declared elections two years ahead of schedule in a bid to seek a third term in office -- has been roundly defeated.

Early trends on Friday morning indicated almost immediately that the opposition candidate, Maithripala Sirisena, was on course to win the 50 percent needed for a victory.

Rajapaksa tweeted his acceptance of the results, and said that he was looking forward to a peaceful transition of power.

The verdict has shocked commentators and common people alike. This election was Rajapaksa’s to lose. It had been the soon-to-be former Sri Lankan President’s decision to call for early elections. He seemed to enjoy widespread support because of his role in ending the Sri Lankan civil war.

How did the gamble go so wrong?

Things began to get complicated from the get-go. The day after Rajapaksa declared the elections, Sirisena -- a former Health minister in Rajapaksa’s cabinet and widely perceived to have been the ‘Number 2’ in Rajapaksa’s party -- quit the government and declared his candidacy.

Other important defections followed.

The country’s main party of Buddhist monks, the Sri Lankan National Heritage Party (JHU), pledged support to Sirisena, delivering another blow to Rajapaksa, who retained the support of the Bodu Bala Sena, or Buddhist Force.

Then a key minister and his minority Muslim party quit the coalition government. Industry and Commerce Minister Rishad Bathiudeen, leader of the All Ceylon Muslim Congress, said that he was switching allegiance to Sirisena.

Bathiudeen explained his switch by alleging that Rajapaksa had failed to restrain radical Buddhist groups involved in attacks on mosques, churches and businesses run by religious minorities in the Buddhist-majority country. "I asked the president to stop these religious hate attacks, but he failed to take action against offenders," Bathiudeen told reporters in Colombo.

Although Muslims, the second largest minority in Sri Lanka after Hindu Tamils, account for only 10 percent of the electorate -- they are be a key vote bank when the Sinhalese vote is split, given that both Rajapaksa and Sirisena are members of the majority Sinhala Buddhist community.

The country’s largest Muslim party, the Sri Lanka Muslim Congress, followed. Ameer Faaiz, a leader of the party that represents minority Muslims in overwhelmingly Buddhist Sri Lanka, cited the Rajapaksa administration’s “intolerance toward religious minorities” and disagreement with his style of rule. The decision served a major setback for Rajapaksa as with it more than 20 lawmakers and ministers defected to the opposition.

More bad news came soon after. Tamil National Alliance leader Rajavarothayam Sampanthan said his party will back Sirisena because Rajapaksa failed to bring to a close the country’s long-standing ethnic conflict, despite ending 25 years of civil war in 2009.

“We are inclined to the view based particularly on the performance of President Mahinda Rajapaksa in the past, that we would rather repose our faith in the joint opposition candidate Mr. Maithripala Sirisena, rather than expect what has not happened in the past 10 years to happen hereafter," Sampanthan said.

More recently, last week, the key defender of Sri Lanka's controversial casino policy -- Faizer Mustapha, a president's counsel and deputy minister of investment -- quit the government and declared his support for the opposition.

The opposition managed to unite themselves under Sirisena and develop a list of tangible promises. The joint opposition agreed to a Memorandum of Understanding. If Sirisena wins, Sri Lanka’s Presidential system will be replaced by a parliamentary system within one hundred days. The 18th amendment to the constitution will be appealed -- meaning that crucial institutions such as the police and judiciary will regain their independence. The 18th amendment, passed in 2010, also eliminated presidential term limits, allowing Rajapaksa to run for a third term.

Sirisena also made an effort to distance himself from perceptions of corruption and nepotism that have come to be associated with the governing party. Announcing a series of reforms, Sirisena vowed to stop Sri Lanka from “moving towards a dictatorship.” He raised issues such as the rising cost of living, wages, corruption, the rule of law, and the welfare state.

This is important because although Rajapaksa continued to enjoy support because of his role in ending the civil war, allegations of corruption and nepotism sprung up. Two weeks after Rajapaksa was re-elected, the losing candidate -- a leading general in the fight against the LTTE -- was jailed. The government took legal action against the opposition and critics, and reports on the curtailment of press freedom continue to pour in.

Rajapaksa also appointed his two brothers to head major government ministries and his cousins as ambassadors to key countries, including Russia and the United States. Another brother was appointed Speaker of Parliament.

In fact, during the run up to the elections, civil rights groups and the opposition rang alarm bells accusing the government and the security establishment of coercing voters. The army, they said, was being deployed to deter Tamils from casting their vote against Rajapaksa in the country’s north. Further, in the few weeks leading to the elections, recordings surfaced where anonymous callers -- appeared to be connected to the security establishment -- issued death threats to leading human rights activists who were campaigning for the opposition.

Perhaps because of the perceived attempt at concentration of power, Rajapaksa’s share of votes plunged in the by-elections and provincial elections last year. The decision to announce the elections two years ahead of schedule is linked to this, with Rajapaksa gambling on the belief that he stands a better chance of being re-elected now, as opposed to waiting for two years and risking a further decline in support.

Wrong move, but who would have known?