The Maldives government has ordered the security forces to resist any move by the Supreme Court to arrest or impeach President Abdulla Yameen.
The court on Friday had ruled the trial of exiled ex-President Mohamed Nasheed unconstitutional and ordered the release of nine MPs, which would see the opposition majority restored.
Refusing to comply, the government instead suspended parliament.
The attorney general said any move to arrest the president would be illegal.
Attorney General Mohamed Anil appeared at a press conference on Sunday with the defence chief, Gen Shiyam, and Commissioner of Police Abdulla Nawaz, whose predecessor had been sacked for saying he would apply the court’s ruling.
Mr Anil said he believed the Supreme Court might try to rule that the president could no longer remain in power.
He said: “We have received information that things might happen that will lead to a national security crisis.
“Any Supreme Court order to arrest the president would be unconstitutional and illegal.
“So I have asked the police and the army not to implement any unconstitutional order.”
In a ceremony broadcast live on TV, leading military and police officers swore an oath to sacrifice their lives to defend the government.
Later, hundreds of opposition supporters gathered in the capital, Malé, to stage a night-time rally demanding the release of political prisoners and respect for the country’s constitution.
A spokesman for the opposition Maldivian Democratic Party, Hamid Abdul Ghafoor, said police had been trying to arrest two top judges, including the chief justice, over allegations of bribery.
He said the government was trying to usurp the powers of the judiciary.
Mr Nasheed has described the government’s refusal to obey the court order as tantamount to a coup.
Mr Nasheed, who is currently in Sri Lanka, said the government and President Yameen must resign immediately and he urged the security services to uphold the constitution.
On Friday, the court had ordered the immediate release of the nine and retrials for Mr Nasheed and other opposition leaders.
It said their trials, which the opposition says they were politically motivated, had violated the constitution.
The ruling effectively reinstated 12 opposition MPs who had been stripped of their seats, so restoring the opposition majority.
The government responded on Saturday by shutting down parliament indefinitely.
On Sunday two opposition lawmakers returning to the country were detained by police.
The country has seen political unrest since Mr Nasheed, the island’s first democratically elected leader, was convicted in 2015 under anti-terrorism laws for ordering the arrest of a judge.
His conviction and 13-year sentence were internationally condemned, and he was given political asylum in the UK after being allowed to travel there for surgery.
The Indian Ocean nation became a multi-party democracy in 2008 but since President Yameen took power in 2013 it has faced questions over freedom of speech, the detention of opponents and the independence of the judiciary.