The Maldives Supreme Court has ordered the release of imprisoned politicians, including an ex-president and an ex-vice president who were jailed allegedly after flawed trials.

The order given Thursday night could be a major blow to President Yameen Abdul Gayoom who has a tight grip on power, controlling institutions like the judiciary, police and the bureaucracy.

It also means the archipelago state's first democratically-elected president Mohamed Nasheed jailed on terrorism charges, Gayoom's former deputy Ahmed Adeeb jailed for allegedly plotting to kill the president and a host of other imprisoned politicians could be set free.

Maldives, known for its luxury tourist resorts became a multiparty democracy 10 years ago after decades of autocratic rule. However, it has lost much of its democratic gains since Gayoom was elected in 2013.