The European Court of Human Rights (ECHR) on Tuesday urged Turkey to swiftly process the legal case of the ex-head of the pro-Kurdish opposition, saying his pre-trial detention had gone on longer than could be justified.
Selahattin Demirtas, former co-chairman of the Peoples' Democratic Party (HDP) and one of Turkey's best known politicians, was sentenced in September to more than four years in jail on terrorism charges related to a speech he gave in 2013.
Having already spent nearly two years in prison awaiting trial for those alleged offences, he had effectively already served out the prison term handed down by the Turkish court.
But Demirtas remains in prison facing several more terrorism-related charges, mostly for other speeches he gave, that could see him sentenced to up to 142 years in jail if found guilty.
"The Court found that the judicial authorities had extended Mr Demirtas' detention on grounds that could not be regarded as 'sufficient' to justify its duration," the Strasbourg-based ECHR said in a statement.
The ECHR ruled that Ankara "was to take all necessary measures to put an end to the applicant's pre-trial detention."
Turkish Justice Minister Abdulhamit Gul dismissed the court's ruling, saying the country's judiciary would decide on Demirtas' cases.
The government accuses the HDP of links to the outlawed Kurdistan Worker's Party (PKK), considered a terrorist organisation by Turkey, the European Union and the United States. The HDP denies this.
The ECHR also criticised Turkey for keeping Demirtas detained during two elections: a constitutional referendum in 2017 and this year's presidential ballot.
"The extensions of Mr Demirtas' detention, especially during two crucial campaigns... pursued the predominant ulterior purpose of stifling pluralism and limiting freedom of political debate," it said.
The court, which awarded Demirtas 10,000 euros ($11,430) in damages and a further 15,000 euros in costs, ruled against a number of his other complaints and accepted that he had been arrested and detained on "reasonable suspicion" of having committed a criminal offence.
Kati Piri, EU Rapporteur on Turkey, said the clear ECHR verdict meant Demirtas should be released immediately. "His detention is of a political, not a criminal nature."
Kerem Altiparmak, a prominent Turkish human rights advocate and professor, also called for Demirtas' immediate release, as his pre-trial detention was now in violation of both domestic and international law.
ECHR rulings are in theory binding, but there have been many instances in which Turkey has not implemented them, paying fines instead.
Having already spent nearly two years in prison awaiting trial for those alleged offences , he had effectively already served out the prison term handed down by the Turkish court.