Hundreds of Kurdish activists have also been caught up in the crackdown.

Turkey must release a leading opposition politician who has been held in detention since 2016, the European Court of Human Rights (ECHR) ruled on Tuesday.

The court said pro-Kurdish politician Selahattin Demirtas' initial arrest on charges including terrorism offences had been justifiable.

But repeated extensions of his detention since then were politically motivated and could not be justified, the Strasbourg-based court ruled.

Demirtas' People's Democratic Party (HDP) said the ruling meant he and other jailed party lawmakers should be released immediately.

The ECHR judgement amounted to a call for the release of elected parliamentarians "who represent the will of millions of people," the party wrote on Twitter.

In a major victory for the 45-year-old opponent of President Recep Tayyip Erdogan, the court made a rare ruling that his lengthy pre-trial detention had clearly been politically motivated.

Demirtas had been kept in jail during two crucial votes - a 2017 referendum on extending presidential powers and this year's presidential election - with the aim of "stifling pluralism and limiting freedom of political debate," the court found.

The former joint leader of the HDP contested the presidential election from his jail cell, coming third in the June poll with 8.4 per cent of the vote.

The ECHR ruled that Demirtas' detention had also amounted to an unjustified interference with the performance of his duties as a member of parliament.

The court ordered Turkey to pay him 10,000 euros (11,432 dollars) in damages and 15,000 euros in costs and expenses.

The judgement will become definitive within three months, unless one of the parties lodges an appeal and the court's expanded Grand Chamber agrees to hear it.

Turkish authorities have been cracking down on the opposition, civil servants and the media since an attempted coup in 2016.

More than 77,000 people have been arrested over alleged links to exiled Islamic preacher Fethullah Gulen, whom authorities blame for the coup attempt.

Hundreds of Kurdish activists have also been caught up in the crackdown.