Lawyers applied on Wednesday for Selahattin Demirtas, former leader of Turkey's pro-Kurdish Peoples' Democratic Party (HDP), to be released from jail after a court ruled he was eligible to be set free, an HDP source said. Demirtas, one of Turkey's best known politicians, has been in jail for almost three years and faces several legal cases, mainly on terrorism charges. A Turkish court last week ruled he should be released as the trial continues in the main case against him, in which prosecutors are seeking a jail sentence of up to 142 years. But Demirtas' release was blocked because he had been sentenced to four years and eight months in jail last September over comments he made in a speech in 2013. The HDP source said Demirtas' lawyers had applied for the three years he has spent in jail to be discounted from his existing sentence, which would make him eligible to be released on parole. The European Court of Human Rights (ECHR) has urged Turkey to process his legal case swiftly, saying his pretrial detention has gone on longer than could be justified. A Turkish court last November rejected an appeal for his release. Ankara accuses the HDP of ties to the outlawed Kurdistan Workers Party (PKK), which has waged a decades-long insurgency in Turkey and is considered a terrorist organisation by the European Union, the United States and Turkey. The HDP denies such links. The charismatic politician, often dubbed the Kurdish Obama, was detained in the crackdown under the state of emergency that followed a failed coup in July of that year. If found guilty in the main trial, he risks 142 years in prison. Before his arrest Demirtas was considered one of President Recep Tayyip Erdogan's major rivals. He came in third in last year's presidential election despite running from his prison cell.