Image copyright AFP/Reuters

After a decade in charge of his country, Mahinda Rajapaksa has been dumped out of office in a shock election defeat. The BBC's former Sri Lanka correspondent Charles Haviland assesses his time in office, and the challenges he leaves to his successor.

"It became apparent that [the security forces] were all keen to see the back of Mahinda Rajapaksa," says a worker at a counting station in Colombo who spent the day chatting to police and army officers on duty for the presidential election.

If it is true that the security forces had had enough of President Rajapaksa, such views have been rarely aired.

His government had poured money into the defence budget. He coasted to victory in earlier elections by capitalising on his war victory over the Tamil Tigers, for which most of the Sinhalese majority respected him, brushing aside the evidence of wide-scale Tamil civilian casualties. He and his family occupied many senior government roles, and built fortunes. The Rajapaksas are widely said to control more than 70% of the economy; in conversation Mahinda would often be referred to simply as "Him".

Their dominance has fostered a curious climate, where democratic discourse is circumscribed. Large demonstrations happen, but usually on fairly apolitical subjects like education. Rallies on issues like human rights are relatively small and are often met by staged counter-demos from pro-government mobs. Some journalists attack the government, but mostly in English, which is not widely understood.

Image copyright AFP Image caption Plans to give tax breaks to casinos are among the issues sparking recent protests

Few have been able to raise the subject of atrocities from the war era, which is the subject of a UN investigation. The allegations are against both the security forces and the Tamil Tigers. But most of the Tigers are dead, allowing the authorities to portray the issue as a stick that the UN used to beat Sri Lanka while ignoring the many Sinhalese victims.

The few that mention war crimes are labelled "traitors" - something the surprise victor Maithripala Sirisena did while he was a minister. The government has stuck to the line that civilian casualties were minimal - further inflaming the profound distress of the tens of thousands of Tamils who bore the brunt of them.

Mr Sirisena says he wants to end the island's growing isolation. One big question is whether he will now co-operate with the UN inquiry into the war, or limit himself to a domestic probe.

Image copyright AFP Image caption Maithripala Sirisena spent a long time working very closely with Mr Rajapaksa

The two biggest minorities - Tamils and Muslims - voted for Mr Sirisena in large numbers, and probably swung the vote his way. Their vote was more anti-Rajapaksa than pro-Sirisena. Mr Sirisena was picked by the unwieldy opposition coalition for his Sinhalese appeal, and he has done little to reach out to the minorities on the campaign trail. It will be difficult for him to ignore their grievances now, including constitutional changes for a settlement of the ethnic grievances that fuelled the long war.

Questions also surround Bodu Bala Sena - the hard-line Buddhist monks' organisation that has peddled hatred and violence against Muslims and some Christians for the past two years. Will it simply disappear with the demise of a government that at the very least tolerated it?

Victims of other human rights abuses - including many dating from before the Rajapaksa era - will also be seeking redress. Will the Fourth Floor of the Criminal Investigation Department continue to be a place notorious for torture, or will that change? Will people like Shiromani Prabagaran, whose husband was abducted in a Colombo street in 2012 and never seen again, get answers on the fate of their close family?

Image copyright AP Image caption Many people will hope the new president listens to their grievances, particularly in Tamil areas

It is too early to tell. But Mr Sirisena has made firm promises on the rule of law. He has vowed to abolish the constitutional change that allowed presidents unlimited terms and eroded their accountability. He is to hold parliamentary elections on 23 April, leading to a national government of all elected parties. Reports also say he is ready to reinstate Shirani Bandaranayake, the former chief justice whose sacking Mr Rajapaksa engineered two years ago.

Geopolitically, Sri Lanka has drawn ever close to China for loans and investment in building new infrastructure. The resultant new motorways and restored railways have been impressive, but Beijing's involvement has provoked a nervy response from traditional ally India. Mr Sirisena says he will treat key Asian countries - India, China, Pakistan and Japan - equally.

Mr Sirisena's coalition will struggle to stick together. At its core is the United National Party, generally seen as pro-business and moderately pro-Western, which was at the helm during some of the most controversial and blood-soaked episodes in the island's modern history. The coalition also includes former Prime Minister Chandrika Kumaratunga, under whose rule an abortive ceasefire agreement was signed; and a Buddhist nationalist party that takes an exceptionally hard, anti-devolution line on the Tamil issue.

Placating all these elements, and keeping Tamils and Muslims minimally well-disposed towards him, will not be easy for the new President Sirisena.