The government had expressed "concerns" over the judicial order and resisted complying with it, but the court said there can be no excuses.
Dissidents must be released because their trials were politically motivated and flawed, the Supreme Court said in a statement.
"There is nothing preventing the prosecutor general from seeking a re-trial after the order has been implemented (and prisoners released)," it added.
Thursday's order to restore the seats of 12 government MPs who defected to the opposition would effectively reduce Yameen's party to a minority and expose him to the risk of impeachment.
More From This Section
The main opposition Maldivian Democratic Party (MDP) said its MPs tried to stage a meeting in defiance of a weekend order suspending parliament, but they were pushed back by armed troops.
Security forces have been deployed inside the national parliament - known as the People's Majlis - since March last year when Yameen ordered them to evict dissident lawmakers.
The president's crackdown on dissent has tarnished the Maldives' image as an upmarket holiday paradise and sparked calls from the United Nations and several countries to restore the rule of law in the fledgling democracy.
In a national television address today, Attorney General Mohamed Anil remained defiant.
"Any Supreme Court order to arrest the president would be unconstitutional and illegal," Anil said. "So I have asked the police and the army not to implement any unconstitutional order."
Yameen also sacked two police chiefs after the court's decision.
Atul Keshap, the US ambassador to Sri Lanka and the Maldives, led international criticism of the Yameen government's refusal to respect court orders.
"What security risk prevents the #Maldives #Majlis from meeting tomorrow? Why are MPs pepper sprayed in the streets and arrested on arrival at airport?" he tweeted today.
Nasheed, who was controversially convicted of a terrorism charge and jailed for 13 years in 2015, urged police and troops to uphold the constitution.
"Statements made today by AG Anil... to disobey SC orders is tantamount to a coup. They, and President Yameen must resign immediately," he tweeted on Sunday.
"Security services must uphold the constitution and serve the Maldivian people."
Nasheed, the country's first democratically elected leader, was toppled in 2012. He was barred from contesting elections after his 2015 terrorism conviction, which was internationally criticised as politically motivated.
The MDP - which is led by Nasheed - has expressed fears that any move by the government to resist the Supreme Court's order may trigger unrest in the nation of 340,000 Sunni Muslims.