ISTANBUL (Reuters) - A Turkish journalist was handed a suspended sentence of two years and five months in prison on Thursday for insulting Turkey’s President Tayyip Erdogan, a court ruling seen by Reuters showed.

FILE PHOTO: Turkish President Tayyip Erdogan addresses members of parliament from his AK Party (AKP) in Ankara, Turkey, October 23, 2018. REUTERS/Tumay Berkin/File Photo

Husnu Mahalli, a prominent journalist who also writes columns in the opposition newspaper Sozcu, will not be sent to jail due to time already served and as the ruling is up for appeal.

The Turkish court also handed Mahalli a suspended sentence of one year and eight months for insulting public officials.

Mahalli will only serve the lesser sentence if he commits a crime that requires a prison sentence in the next five years, during which he will be on probation.

“My client has been sentenced due to the expressions he used in his columns, tweets. These should be regarded within the freedom of criticism. We will appeal the sentence,” Mahalli’s lawyer Ertugrul Aydogan said.

Mahalli was detained in December 2016 after he accused Turkey of assisting terrorist groups in Syria and called Erdogan a dictator. He was released in January in 2017 pending trial.

Mahalli defended himself in court, saying he was doing his journalistic duty, private Demiroren news agency (DHA) reported.

“I have not insulted the president. I have always addressed him as Mr. President. The word ‘dictator’ is not an insulting word. I demand my acquittal,” he said during his defense, DHA said.

Turkish authorities have detained tens of thousands of civil servants, journalists, soldiers and others following a failed military coup in July 2016. They have also shut down about 130 media outlets.

Erdogan has said some journalists helped nurture terrorists through their writing, and says the crackdown is needed to ensure stability in Turkey, a NATO member that borders Syria, Iraq and Iran.

Critics say Erdogan is using the post-coup crackdown to muzzle dissent and tighten his grip on power, charges he denies. The European Union, which Turkey aspires to join, has also criticized the crackdown.