Turkey's top court on Thursday ordered the release of jailed lawmaker Can Atalay, ruling for the second time that his rights had been violated.
The case of Atalay, 47 -- who ran from jail in May's general election and was elected to parliament -- has created an unprecedented judicial crisis.
Atalay was elected to serve as a member of the leftist Workers' Party of Turkey (TIP).
Before that however, he was one of seven defendants who in April 2022 jailed on charges of attempting to overthrow the government for organising 2013 mass protests.
He got an 18-year sentence in a trial that also saw civil society leader Osman Kavala jailed for life.
Atalan's status sparked a judicial crisis in November when President Recep Tayyip Erdogan accused the highest court of making a series of mistakes.
He backed an unprecedented criminal investigation against its judges by the Supreme Court of Appeals.
In October, the Constitutional Court had ruled that Atalay enjoyed the immunity from prosecution granted to elected lawmakers. It ordered the Supreme Court to reverse its earlier decision to keep the lawyer in jail.
The Supreme Court refused to comply and filed a criminal complaint against the Constitutional Court judges who had sided with Atalay.
The Constitutional Court convened again Thursday to discuss Atalay's situation.
Their majority ruling said Atalay's rights to be elected and engage in political activities guaranteed under the constitution had been violated.
His right to liberty and security had also been violated, it ruled in a majority ruling. The court unanimously ordered the politician's release.
Under Turkish law, a convict eligible to run in the parliamentary elections and who is elected should be released after the official election results are published.
But they still have to serve the rest of their sentence once their parliamentary term is over.
Main opposition CHP party's leader Ozgur Ozel, posting on social media after the court ruling, said Atalay should be freed "as soon as possible" under the constitution.
"Resisting this ruling means ignoring the constitutional legal order," he commented. "We will continue to defend justice and law."
Erdogan has said the judicial standoff highlights the need for Turkey to adopt a new constitution.
But opposition groups fear the government might attempt to eliminate the Constitutional Court with a new charter.
In November, the European Union said in its annual report on Turkey's membership bid that there were serious deficiencies in the functioning of its democratic institutions.
The report said serious backsliding continued and, despite several judicial reform packages in recent years, the structural deficiencies in the judicial system remained unaddressed.
Atalay is a lawyer by profession who has acted in a number of prominent cases.
He represented the families of bereaved following a 2014 coal mine explosion in the Western town of Soma that killed more than 300 miners.
He also acted for the plaintiffs following a train derailment in northwest Turkey that killed 24 people and injured more than 300.