MALE, Maldives (AP) — The Maldives' top court has annulled a conviction for the country's former president on terror charges that carried a 13-year prison sentence.

The Supreme Court on Monday set aside Mohamed Nasheed's conviction, saying there were no grounds for him to be charged under the terrorism law and that the state had failed to produce sufficient evidence.

Nasheed, who became Maldives' first democratically elected president in 2008, was sentenced to prison in 2015 for ordering the detention of a top judge when he was president in 2012. The court said at the time that the judge's arrest amounted to abduction.

After one year in prison, Nasheed traveled to Britain for medical treatment and took asylum there.

He returned home after strongman Yameen Abdul Gayoom lost a presidential election in September.

Nasheed was elected president in 2008, when the Maldives held its first multiparty presidential election, ending decades of autocratic rule. He resigned in 2012 amid public protests over the judge's detention.

He lost the 2013 election to Yameen, who rolled back many of the democratic gains. Yameen jailed almost all of his political rivals, including Nasheed, after rushed trials that were criticized for a lack of due process.

Unable to contest the 2018 presidential election because of his jail sentence, Nasheed backed Ibrahim Mohamed Solih, who won the election.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.