Algeria's former counterterrorism chief was sentenced on Thursday to five years in prison for destroying documents and disobeying military orders, his lawyer said.

Abdelkader Ait-Ouarabi, known as General Hassan, was tried behind closed doors in a military court in second city Oran in the country's first ever prosecution of a high-ranking secret service officer.

Lawyer Khaled Bourayou described the sentence as "retribution", saying his client had "not benefited from extenuating circumstances such as his age, his health and his contribution to the anti-terrorist battle".

Journalists had not been allowed to attend the hearing, even before the judges ordered it held behind closed doors.

For two decades, General Hassan had embodied the army's fight against religious insurgents.

He was forcibly retired on the orders of a military judge at the end of 2013 and placed under surveillance, then arrested in August.

Analysts interpreted his removal as President Abdelaziz Bouteflika consolidation of his hold over the intelligence services, which some considered a "parallel state" within Algeria.

In September, the president also replaced General Mohamed Mediene - better known as General Toufik - after 25 years at the head of the powerful DRS intelligence agency.

In a statement published in Algerian newspapers on Thursday, General Hassan's lawyers said that he was "a collateral victim of the ferocious clan war being waged at the highest level of politics".

The former general was "one of the valiant officers who saved the country from the perils of terrorism", Bourayou and Ahmed Touphali Tayeb said.

"If he is condemned, what signal will Algeria be sending to all those who - here and worldwide - are waging a relentless battle against internal and transnational terrorism, which has increased in ferocity in recent years?"