A Turkish court has sentenced six journalists to life in prison in relation to a failed coup attempt in 2016, state media reported.

The six journalists received aggravated life sentences for "attempting to overthrow the constitutional order", an unnamed judicial source told Anadolu news agency on Friday.

Turkey has accused the journalists of having links to a movement headed by exiled Muslim scholar Fethullah Gulen, who Ankara alleges was behind a deadly failed putsch in July 2016. Gulen, who is based in the United States, denies the accusation.

The individuals sentenced on Friday in the Istanbul court include Ahmet Altan, the former editor-in-chief of Taraf newspaper, his brother, journalist and academic Mehmet Altan, and prominent Turkish journalist Nazli Ilicak.

The journalists, who had been detained for about a year, can appeal the ruling all the way up to the Turkish Supreme Court, Al Jazeera's Sinem Koseoglu reported from Istanbul.

"Aggravated life sentence means if prisoners are granted immunity by any other future government or any other judiciary, these people cannot benefit from that," Koseoglu said.

In a post-coup purge, Turkey detained and summarily fired tens of thousands of people, including journalists, academics, teachers, civil servants and police officers, for allegedly having links to the Gulenist movement.

About 150 Turkish journalists are believed to be imprisoned in Turkey, according to the European Centre for Press and Media Freedom (ECMPF) said.

With the life sentence for the journalists #AhmetAltan #MehmetAltan & #NazlıIlıcak, the Turkish judiciary and the regime that controls the judges ridicule themselves in front of the world #PressFreedom #Turkey pic.twitter.com/G9jnkmQfEW — Christophe Deloire (@chrisdeloire) February 16, 2018

The ruling on Friday was condemned by press freedom and human rights groups.

Christophe Deloire, secretary-general of Reporters Without Borders, said that "the Turkish judiciary and the regime that controls the judges ridicule themselves in front of the world" with the ruling.

"This sets a devastating precedent for scores of other journalists charged with similarly groundless charges," said Sarah Clarke, policy and advocacy manager at PEN International, a freedom of expression advocacy group.

Turkish-German journalist released

The sentences came a few hours after Turkish-German journalist Deniz Yucel was released after more than a year in prison.

"We are relieved and happy about the news," Lutz Kinkel, ECMPF managing director, said in a statement.

Yucel still faces a charge of "supporting terrorism", which comes with a maximum sentence of 18 years in prison, the ECMPF said.

Sigmar Gabriel, Germany's foreign minister, welcomed Yucel's release.

"This is a good day for all of us," he said in a statement.

“I am very pleased with this decision by the Turkish judiciary. And I am even happier for Deniz Yucel and his family," he added.

Gabriel thanked the Turkish government for expediting the case and said it "has always emphasised that it will not exert any political influence on the court's decision-making".