The Maldives Supreme Court has hit back at President Abdulla Yameen's refusal to free his jailed opponents amid an escalating crisis that saw security forces seal off the country's parliament and arrest two opposition lawmakers on Sunday.

Judges of the top court said there should be "no legal barrier" to releasing the nine people, including the island nation's exiled former president Mohamed Nasheed, whose terrorism and corruption convictions it overturned last week.

Their statement came after Attorney-General Mohamed Anil raised concerns about freeing people convicted of "terrorism, bomb attacks, corruption, embezzlement and fraud".

The top court's ruling last week has plunged the Maldives into political turmoil and dealt a major blow to Yameen, who critics accuse of corruption, misrule and rights abuses.

He denies the allegations.

The sudden about face by the Supreme Court, which sided with Yameen in the past, and the widespread international support for its verdict puts unprecedented pressure on the president to free his opponents ahead of a presidential election later this year.

{articleGUID}

The government accused the Supreme Court of trying to oust the president, a claim judges did not respond to in their statement late on Sunday.

Earlier in the day, the attorney general, in a televised appearance flanked by the chiefs of the army and the police, said the government has received news of an imminent order by the Supreme Court to impeach Yameen.

"I have informed all law enforcement agencies they must not obey such an illegal order," Anil said.

Ahmed Shiyam, the army chief, said the security forces would follow the attorney-general's advice and "will not wait and watch as the Maldives descends into crisis".

The opposition called Anil's order to the security forces "unconstitutional, highly illegal, and dangerous" and petitioned parliament to oust Anil, as well as the country's chief prosecutor.

Shortly afterwards, soldiers surrounded the parliament building and sealed it off.

The opposition now have a majority in the 85-member house as the Supreme Court ruling also reinstated 12 members of parliament who were stripped of their seats last year.

But two of the 12 were arrested at the airport on Sunday, shortly after they returned to the Maldives after spending months in exile.

Abdulla Sinan and Ilham Ahmed were detained on charges of bribery, a police spokesman told Al Jazeera.

{articleGUID}

Ibrahim Mohamed Solih, an opposition parliamentarian, condemned their arrest in a statement.

"We call on the police to release the MPs immediately, and to stop following unlawful orders, to stop obstructing the lawful mandate of parliamentarians," Solih said.

"In a desperate attempt to cling onto power, President Yameen has illegally overrun the state. His attorney-general has illegally assumed the powers of the apex court, while the military has overrun the legislature," he added.

On Sunday night, hundreds of flag-waving opposition supporters took to the streets of the capital Male calling on the government to abide by the court ruling.

#HappeningNow

Peaceful protesters gathered near #MDP Haruge with joined MPs continue to call on the govt to follow the Supreme Court's ruling & to stop intimidating the judiciary.#Maldives pic.twitter.com/89JDD2EZj7 — Nauty 🎈 (@nautymatox) February 4, 2018

The ruling party also held a rally in support of Yameen.

tonight’s rally in support of the government and President Yameen..🇲🇻 #Maldives pic.twitter.com/uFCKu90O24 — Mohamed Saeed (@em_saeed) February 4, 2018

Meanwhile, the official who heads the parliament's secretariat resigned after the speaker, a Yameen ally, cancelled the opening of the parliament, scheduled for Tuesday, over unspecified "security concerns". .

"I have stepped down," Ahmed Mohamed told Al Jazeera on Sunday, without offering further details.

The heads of the Maldives' main high-security prison and the elections commission have also quit in recent days.

Nasheed, speaking to a private television channel from neighbouring Sri Lanka on Sunday, called for protests and urged rank-and-file members of the security forces to arrest the attorney-general as well as the chiefs of the army and police.

Anil's statements were "tantamount to a coup", the former president said in a post on Twitter.

The United Nations, European Union, and several foreign governments including India, the US and UK, have urged Yameen to comply with the Supreme Court's ruling.

Additional reporting by Hassan Moosa from Male