A top Turkish court on Wednesday ordered the release of journalist and novelist Ahmet Altan, who was jailed for his alleged involvement in a failed 2016 coup attempt.

The Court of Cassation ruling came a day after the European Court of Human Rights (ECHR) demanded the release of Altan, who has spent more than four years behind bars after writing articles critical of President Recep Tayyip Erdogan.

The 71-year-old was arrested shortly after the putsch attempt as part of a purge of media organisations and accused of supporting the uprising by "disseminating subliminal messages to the public".

He was subsequently sentenced to life imprisonment for trying to overthrow the government, a ruling that was later quashed by Turkey's top court.

After the case was re-examined, he was sentenced to 10 years and six months in prison for "knowingly supporting a terrorist organisation", a reference to a movement Erdogan alleges was behind the coup.

He has always denied the charges, calling them "grotesque".

Altan was briefly released in November 2019 for time already served, but then almost immediately re-arrested and convicted of new terrorism charges.

The Court of Cassation ruling on Wednesday overturned his conviction in the 2019 case.

Writer Ahmet Altan waw arrested shortly after the 2016 coup attempt as part of a media purge
Writer Ahmet Altan waw arrested shortly after the 2016 coup attempt as part of a media purge AFP / BULENT KILIC

He had turned to the ECHR for help in 2017.

In its verdict announced Tuesday, the Strasbourg-based rights court found "no evidence that the actions of the applicant had been part of a plan to overthrow the government".

The Court of Cassation ruling was issued as Erdogan attempts to repair relations with the European Union, which highlighted Turkey's deteriorating human rights record during a summit in Ankara last week.

Although Turkish officials argue that the courts are independent, critics accuse Erdogan of stacking them with supporters during the sweeping purges that followed the coup attempt.

Altan's case is one of several Western observers are watching for signs of Turkey's diplomatic intentions and future political course.

Perhaps the most celebrated case involves civil society leader Osman Kaval, who has been in custody without a conviction for nearly four years.

In the case of Altan, the ECHR ordered Turkey to release him and pay him 16,000 euros ($19,000) in damages for violating his rights to freedom of expression.

His arrest had no basis in any "reasonable suspicion" that he had indeed committed the alleged criminal offences, the ECHR found.