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.
Police detained two opposition lawmakers who returned to the country Sunday as the political crisis in the Indian Ocean archipelago nation deepened with its top court pitted against the president.
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.
'Unconstitutional and illegal'
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.
But the Yameen government has so far refused to comply with the shock ruling, resisting international pressure.
In a national television address on Sunday, 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."
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 Sunday.
Former president and current opposition leader Mohamed Nasheed described the government's refusal to obey the Supreme Court as a "coup".
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.
He has been in exile since 2016, when he left on prison leave for medical treatment. He is currently in Colombo, meeting Maldivian dissidents based in Sri Lanka.
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.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)
Get the latest election news, live updates and election schedule for Lok Sabha Elections 2019 on ndtv.com/elections. Like us on Facebook or follow us on Twitter and Instagram for updates from each of the 543 parliamentary seats for the 2019 Indian general elections.