The exiled former president of the Maldives has said he will run again for office, hours after a surprise supreme court decision to free a group of political prisoners led to unrest in the capital of the Indian Ocean archipelago.

President Yameen Abdul Gayoom had been set to run for re-election virtually unopposed, with all of his opponents either jailed or exiled, but the former president Mohammed Nasheed, who was among those freed, said he would be a candidate. Yameen has rolled back many democratic reforms since coming to power five years ago.

Nasheed was jailed in 2016, but received asylum in Britain later the same year after travelling there on medical leave from prison. He has lived in exile ever since.

“I can contest and I will contest and hopefully we will win it again,” he said from Colombo, Sri Lanka.

The court ruling on Thursday night ordered the release of nine political dissidents, saying their guilty verdicts had been politically influenced. It ordered fresh trials for all nine, but it was not immediately clear how this might affect the elections. The opposition alliance welcomed the ruling in a statement, saying it “effectively ends President Yameen’s authoritarian rule”.

Hundreds of flag-waving Nasheed supporters poured into the streets of Malé after the verdict. Clashes broke out quickly after Yameen fired the country’s police chief, whose department had announced it would uphold the supreme court verdict.

The clashes lasted about three hours, and police dispersed stone-throwing crowds using pepper spray and batons. At least one injured police officer was taken to hospital. It was not immediately clear if there were any arrests, but some protesters were taken away by police.

Malé was quiet on Friday afternoon, but an opposition leader said further protests were planned.

Atul Keshap, the US ambassador to the Maldives, welcomed the supreme court order. “I urge the government and security services to respect this ruling, which bolsters democracy and rule of law for all Maldivians,” he wrote on Twitter.

An archipelago known for its luxury tourist resorts, the Maldives became a multiparty democracy 10 years ago after decades of autocratic rule by the president’s half-brother, Maumoon Abdul Gayoom.

Yameen has maintained a tight grip on power, controlling institutions such as the judiciary, police and the bureaucracy. The half-brothers have since fallen out, and Maumoon has joined the opposition.