ANKARA (Reuters) - Turkey’s appeals court has overturned coup plot convictions imposed in 2013 on a retired military chief and scores of senior figures in a case then regarded as clipping the wings of the secularist and military establishment, state media said on Thursday.

Former army chief Ilker Basbug (C) speaks to media after being released from prison outside Silivri prison complex near Istanbul March 7, 2014. REUTERS/Osman Orsal

The ruling closes the final chapter in a nine-year legal drama whose twists and turns have tracked the shifting balance of power at the heart of the Turkish establishment.

In August 2013, ex-military chief General Ilker Basbug was sentenced to life in jail for his role in the “Ergenekon” plot to overthrow then-Prime Minister Tayyip Erdogan’s Islamist-rooted government.

Politicians, lawyers and journalists were also among 275 defendants in the case, which emerged in 2007 when an arms cache was discovered in a house in an Istanbul suburb.

It was at the time championed by Erdogan and his supporters as a battle against anti-democratic forces and to tame a military that had seen itself as the guardian of secularism, carrying out three coups and forcing a fourth, Islamist-led government from power in the second half of the 20th century.

In Thursday’s ruling, the appeals court said there had been no “Ergenekon terror group”, and that evidence had been collected illegally, the state-run Anadolu Agency reported.

SLEDGEHAMMER

After the 2013 convictions, the case became entwined in a power struggle between Erdogan and U.S.-based Muslim cleric Fethullah Gulen, whose influential followers in the judiciary had been seen as key to the Ergenekon convictions.

Erdogan accused Gulen of using his influence within state institutions to try to unseat him in a coup plot. As their feud deepened, the Ergenekon defendants were released in March 2014, with the government suggesting they too may have been unfairly treated and the victims of a Gulenist plot.

Another trial over an alleged 2003 plot against Erdogan, the “Sledgehammer” case, ended with acquittal for more than 200 military officers in March last year.

The prosecutor who led the Ergenekon investigation, viewed as close to Gulen, fled to Armenia in August as an arrest warrant was issued for him over his role in a separate investigation of alleged corruption in Erdogan’s inner circle.

That corruption inquiry was thrown out by the courts and the judiciary and police subjected to a systematic purge of suspected Gulen supporters.

Police operations have subsequently targeted thousands of supporters of Gulen, accused of leading what prosecutors described as a “Gulenist Terror Group” trying to overthrow Erdogan. Gulen denies the accusations.