An Istanbul court on Wednesday handed multiple prison sentences to five reporters convicted of violating the law on coverage of Turkey's spy agency but ordered their release pending appeals.

Six journalists faced up to 20 years in prison on charges of exposing state secrets and violating the Turkish Intelligence Agency (MIT) law.

The closely-watched trial concerned a news report alleging that a Turkish intelligence officer was killed in Libya in February.

All six journalists were acquitted of the state secrets charge.

But the court sentenced Aydin Keser, Ferhat Celik and Murat Agirel, who work for the pro-Kurdish Yeni Yasam daily, to four years and eight months in jail on the MIT law charges.

It sentenced OdaTV editor-in-chief Baris Pehlivan and reporter Hulya Kilinc to three years and nine months on the same charges, while acquiting OdaTV news director Baris Terkoglu.

Demonstrators rallied outside the Turkish court with posters calling for press freedom
Demonstrators rallied outside the Turkish court with posters calling for press freedom AFP / Ozan KOSE

They were all released pending appeals, one of the defence lawyers Serkan Gunel told AFP.

Pehlivan, Kilinc and Agirel had been in jail since March.

"What I have done is only journalism," Kilinc told the judge earlier in her defence. "I have been a journalist for 20 years. I have no intention to commit a crime."

OdaTV reported in March that the intelligence officer had been quietly buried in his hometown of Manisa in western Turkey.

The report also featured photos from the funeral and identified the officer by his first name and the initial of the last name.

Turkey, whose government is under fire from rights groups for stamping on press freedom, is ranked ranked 154th out of 180 countries on the Reporters Without Borders press freedom list.