Image copyright AFP Image caption Mohamed Nasheed was elected in 2008 on a platform of democracy and change

Just over three years ago, supporters of then President Mohamed Nasheed lined up along the seawall in the capital, Male, waving flags to usher in what they called the "dawn of democracy".

It was the country's first-ever multiparty election, and the 41-year-old former political prisoner had won out against an incumbent who had ruled autocratically for three decades.

But in a dramatic fall from power, Mr Nasheed - known as Anni to his supporters - on Tuesday stepped down after what his party described as a "coup against a constitutionally-elected government".

Galvanised by the opposition, protesters had taken to the streets to demand his resignation and were joined by rebel police officers and several dozen unarmed soldiers.

Mr Nasheed, declaring that he did not want to see any bloodshed, announced he was stepping down.

It was a startling turn of events for a man heralded as the harbinger of change who pledged to complete the archipelago's transition to democracy.

In recent years, Mr Nasheed had also attracted worldwide attention for his campaign for action on climate change, even holding an underwater cabinet meeting to highlight his cause.

But domestically, he appeared to lose his footing as a series of crises shook his government, while elements of the former government grappled to regain power.

Religious protests

Early this year, Mr Nasheed came up against religious groups, who demanded more conservative policies in the Sunni Muslim nation.

Image copyright AP Image caption Mr Nasheed's resignation came after rebel police officers mutinied and joined opposition-led protests

Scores of people rallied in the capital after a visit by the UN human rights chief, Navi Pillay, who said the Maldives should hold a debate on the flogging of women accused of extra-marital sex.

Ms Pillay's comments were seen by some as an assault on Islam. Opposition parties jumped on the cause, accusing Mr Nasheed - regarded as a liberal - of being un-Islamic.

Meanwhile, Maldivians expressed anger over soaring prices, which they said were a result of economic policies imposed by the government to tackle a huge budget deficit.

It was, however, Mr Nasheed's intervention in the judicial branch which brought his term to an unexpected end.

Last month he asked the army to arrest Abdulla Mohamed, the chief judge of the Criminal Court, in a move condemned by critics as unconstitutional.

The judge had ordered the release of a government critic he said had been illegally detained. Aides to the president said the judge was obstructing allies of former President Maumoon Abdul Gayoom facing justice.

But opposition parties, the Supreme Court and the Judicial Services Commission said the detention of Judge Mohamed was unlawful and called for his release.

Protests were organised in which demonstrators accused Mr Nasheed of being a dictator. As tensions mounted, the rhetoric became increasingly toxic, with senior opposition figures calling for a mutiny.

On Monday night, a group of police defectors attacked a rallying point used by the ruling Maldivian Democratic Party (MDP) in Male.

The following day, soldiers fired teargas at police mutineers and demonstrators at the Maldives National Defence Force headquarters in Republic Square.

The army later said they advised Mr Nasheed to give up power; Mr Nasheed later said he was forced "at gunpoint".

'Volatile situation'

Image copyright AP Image caption Mohammed Waheed Hassan was sworn in to power on Tuesday

Some regard the unrest as a war between Mr Nasheed and Mr Gayoom's proxies, some of whom have faced allegations of corruption.

Earlier this week, a big fraud case against Mr Gayoom's half-brother, Abdullah Yameen, was forwarded to prosecutors by the presidential commission, an investigative body set up by Mr Nasheed.

Mr Nasheed, who was heavily persecuted under Mr Gayoom, has accused the new President Mohammed Waheed Hassan, formerly vice-president, of being part of a conspiracy with the opposition to oust him. Mr Waheed has denied the claim, saying he only wants to bring stability to the country.

It remains unclear how this crisis will lay the ground for presidential elections expected in 2013.

Judge Mohamed has since been released under the orders of the new president.

Mr Waheed is expected to govern until the polls, but the situation remains volatile.

Events of the last 24 hours have stunned the usually peaceful nation.