Maldives President Abdulla Yameen's administration said on Tuesday it had put down a coup after declaring a state of emergency the day before and arresting two Supreme Court justices and opposition figures.
"We have managed to ensure the failure of the coup attempt by some people," Defence Minister Adam Shareef Umar said on state television.
While the government seemed in control on Tuesday, it was unclear whether the political crisis in the Indian Ocean island nation, best known as a luxury holiday destination, was over.
On the same day, an exiled former president urged regional power India to send an envoy backed by its military to release Maldivian political prisoners.
The Maldives plunged into crisis last week after the Supreme Court quashed terrorism convictions against nine leading opposition figures including the exiled, first democratically elected president, Mohamed Nasheed.
Tensions came to a head when Yameen's government rejected the ruling and on Monday imposed an emergency and then in the early hours of Tuesday morning arrested the chief justice and another judge of the court. In doing so, the government ignored calls from the United States and the international community to respect the court's verdict.
By Tuesday evening, Yameen appeared to have gotten his way with the court when he lifted his suspension of an article of the constitution that establishes the Supreme Court as the final authority on legal matters.
That move was quickly followed by the three remaining court justices who are still free annulling the court's decision to drop charges against the nine opposition figures, according to a statement on the court's website.
Yameen's office released a statement saying his government "welcomed the Supreme Court's revision".
Meanwhile, Nasheed, who was granted asylum by Britain after the Male government allowed him to leave jail for medical treatment abroad in 2016, sought Indian intervention to resolve the nation's most serious political crisis in years.
"On behalf of Maldivian people we humbly request: India to send envoy, backed by its military, to release judges & pol. detainees... We request a physical presence," Nasheed, who is currently in Colombo, Sri Lanka, said in a Twitter post.
He also urged the United States to block the financial transactions of Yameen's government.
Since Yameen took power in 2013, his government has faced heavy criticism over the detention of opponents, political influence over the judiciary and the lack of freedom of speech.
Addressing the nation on state television, Yameen said he had acted to prevent a coup, and suggested that the judges had chosen to side with his opponents because they were being investigated for corruption.
"I declared the state of emergency because there was no way to hold these justices accountable. This is a coup. I wanted to know how well planned this coup is," he said.
As part of the crackdown, police also detained Yameen's half-brother, Maumoon Abdul Gayoom, who had ruled the Maldives for 30 years until 2008 and now stands with the opposition.
Gayoom was detained at his residence along with his son-in-law. But Gayoom's son Faris, who was one of the imprisoned opposition leaders whom the court ordered to be freed, was released on Tuesday, his lawyer told Reuters.
Other opponents of Yameen remained in prison.
Located near key shipping lanes, the Maldives have assumed greater importance since China began building political and economic ties as part of its so-called "String Of Pearls" strategy to create a network of ports in the Indian Ocean.
Having historically held more clout in the islands, India has sought to push back against China's growing influence there.
India, the United States and Britain have urged Yameen to honour the rule of law and free the detainees.
"President Yameen has systematically alienated his coalition, jailed or exiled every major opposition political figure, deprived elected members of parliament of their right to represent their voters in the legislature, revised laws to erode human rights ... and weakened the institutions of government," the US State Department said in a statement.
Indian intervention in the Maldives would not be unprecedented, as New Delhi sent troops in 1988 to foil a coup.
Chinese Foreign Ministry spokesman Geng Shuang said it was an internal matter for the Maldives.
"We believe that the Maldives government, political parties and people have the wisdom and ability to cope with the present situation themselves," Geng told a daily news briefing.
China has had good ties with Yameen’s government and a free trade agreement between the two countries was signed in December, despite criticism from the opposition.
Any Indian involvement would risk raising tensions further in the overwhelmingly Muslim archipelago of 400,000 people and intensify the rivalry with China.
Aside from the 1988 intervention, India has generally tried to avoid meddling in the Maldives' internal affairs, although it has continued to provide military and economic assistance.
The tumult comes during the peak tourism season in Maldives, which earned $2.7 billion in 2016 from holidaymakers visiting luxury hotels and scuba diving resorts scattered round the myriad tiny tropical islands and coral atolls.
China, the United States and India have already issued advisories against travelling to the Maldives, though most tourists would only pass through rather than stay in Male, the densely populated capital where political tensions are highest.
"It has affected business. We have advised our operators to not sell Maldives packages," said Raman Singh Taneja, Managing Director, Flexi Tours Pvt Ltd in New Delhi that sends tour packages. "It's like a coup there, worse than earlier."