Magistrates in Istanbul on Thursday ordered the release of 230 military officers sentenced for plotting to overthrow the government, a day after Turkey’s top court said the original trial was flawed.

The Istanbul court ruled that the sentences of between 13 and 20 years should be suspended until the officers can face a retrial, local media reported.

The first of the officers were already walking free from prison by Thursday afternoon in Ankara and Istanbul, welcomed by dozens of family and supporters.

Among those released on Thursday was the alleged mastermind of the conspiracy, former general Cetin Dogan, as well as former chiefs of staff of the navy and air force.

On Wednesday, a higher court ruled that the officers’ rights had been violated during their trial in 2012 when they were convicted of seeking to bring down the government of Prime Minister Recep Tayyip Erdogan.

The ruling by the Constitutional Court said there were reasons to doubt the evidence and witness statements used in the highly publicized “Sledgehammer” trial.

A total of 13 generals and admirals are included among the 230, as well as around 60 serving officers.

The Turkish army, which formally requested a retrial in December, welcomed the news.

“We share with all our heart the happiness of our personnel and their families and hope that their new trial will reach a just verdict,” the army chief of staff said in a statement.

A total of 326 officers were convicted in 2012 of plotting to foment unrest by launching attacks on mosques and sending planes to provoke a conflict with Greece in order to create the pretext for a coup.

Rights groups have long criticized the trial, questioning the impartiality of the magistrates and arguing it was an attempt by the government to undermine the military.

The defense argued that the Sledgehammer plan — “Balyoz” in Turkish — was only a theoretical exercise prepared by the army in 2003, and that the trial was an attempt by the government to undermine the military, which has carried out four coups since 1960.

The Constitutional Court has been a persistent thorn in Erdogan’s side. It is seen as upholding a constitution that was framed by a former military government, and has overturned or challenged several government decrees in recent years.