Turkey's highest appeals court has overturned the convictions of 275 people over an alleged coup plot against the democratically elected government.
The court in Ankara said on Thursday that there is no evidence the "terror organisation" dubbed Ergenekon was real.
The court also found that the lower court had relied on illegal wiretappings, statements from witnesses whose identities were not revealed, the illegal wiretapping of members of the National Intelligence Organisation (MIT) and unlawful searches for its 2013 verdict.
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.
Politicians, lawyers, officers, academics, 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.
Erdogan's supporters have accused US-based preacher Fethullah Gulen, his one-time ally and now arch enemy, of trying to weaken the country's powerful army by fabricating evidence against officers for the trial.
READ MORE: Hundreds acquitted in alleged coup plot case in Turkey
Turkey's Deputy Prime Minister Yalcin Akdogan took to Twitter after Thursday's ruling to accuse Gulen's network of followers of having "poisoned the judicial process" in the original trial.
The investigation into a possible coup was sparked after the discovery in 2007 of a cache of explosives at the house of a former army officer, which prosecutors said led them to uncover a criminally-minded network.
The armed forces have long wielded power in Turkey, bringing down four governments between 1960 and 1997.
But after falling out in 2014 with Gulen, a self-exiled Muslim cleric who wields tremendous influence across all levels of power, Erdogan said he would favour retrials for those caught up in the alleged coup plot case.
The about-turn followed a huge corruption scandal at the end of 2013 which implicated Erdogan's entourage and which Gulen was accused of masterminding.
The government has since then purged the police and justice system of those suspected of being in cahoots with Gulen.