ISTANBUL (Reuters) - Turkey began freeing 38,000 prisoners on Wednesday, after announcing a penal reform that will make space for tens of thousands of suspects rounded up over last month’s attempted coup.

Major Sukru Seymen (C), one of the military personnel suspected of being involved in the coup attempt, is brought to a court house as he is accompanied by police officers and other detaniees in Mugla, Turkey, August 17, 2016. REUTERS/Kenan Gurbuz

The reform was one of a series of measures outlined on Wednesday in two decrees under a state of emergency declared after the July 15 failed putsch during which 240 people were killed.

The government gave no reason for measure, but its prisons were already straining capacity before the mass arrests that followed the coup.

Western allies worry President Tayyip Erdogan, already accused by opponents of creeping authoritarianism, is using the crackdown to target dissent, testing relations with a key NATO partner in the war on Islamic State.

Angrily dismissing those concerns, Turkish officials say they are rooting out a serious internal threat from followers of a U.S.-based cleric.

Wednesday’s decrees, published in the Official Gazette, also ordered the dismissal of 2,360 more police officers, more than 100 military personnel and 196 staff at Turkey’s information and communication technology authority, BTK.

Those dismissed were described as having links to cleric Fethullah Gulen, a former ally of Erdogan turned enemy. Erdogan says Gulen was behind the attempt by rogue troops using tanks and jets to overthrow the government. Gulen denies involvement.

Under the penal reform, convicts with up to two years left in sentences are eligible for release on probation, extending the period from one year. The “supervised release” excludes those convicted of terrorism, murder, violent or sexual crimes.

“I’m really happy to be released from jail. I wasn’t expecting anything like this,” prisoner Turgay Aydin was quoted by Andolu news agency telling reporters outside Turkey’s largest prison Silivri, west of Istanbul. “I thank President Recep Tayyip Erdogan. I’ve come to my senses. After this I will try to be a better, cleaner person.”

In an interview with A Haber television, Justice Minister Bekir Bozdag said 38,000 people would initially be released, but as many as 93,000 could benefit from the program.

To be eligible for the scheme, prisoners must have served half of their sentences. Previously they were required to have already served two thirds of their sentences.

According to justice ministry data obtained by Anadolu agency, there were 213,499 prisoners in jail as of Aug. 16, more than 26,000 above prison capacity.

Another measure in the decrees gave the president more choice in appointing the head of the armed forces. He can now select any general as military chief. Previously only the heads of the army, navy or air force could be promoted to the post.

A telecoms authority will also be closed under the moves.

Erdogan says Gulen and his followers infiltrated government institutions to create a ‘parallel state’ in an attempt to take over the country.

A total of 40,029 people have been detained in investigations following the coup, and 20,355 of them formally arrested, Prime Minister Binali Yildirim said in a speech late on Wednesday.

He said 79,900 people had been removed from public duty, referring to purges in the civil service that have targeted the military, police, teachers and judiciary. A total of 4,262 companies and institutions with links to Gulen have been shut, he said.

Slideshow ( 5 images )

On Tuesday police searched the offices of a nationwide retail chain and a healthcare and technology company, detaining executives who authorities accuse of helping finance Gulen’s network.

FIRST ‘COUP’ INDICTMENT

A prosecutor in the western province of Usak has submitted the first indictment formally accusing Gulen of masterminding the coup plot, the state-run Anadolu Agency said.

An 11-month investigation focused on alleged wrongdoing by the Gulen movement from 2013, and now includes charges Gulen organized an armed terrorist group to topple the government, scrap the constitution and murder Erdogan on July 15.

The 2,257-page indictment seeks two life sentences and an additional 1,900 years in jail for Gulen, plus tens of millions of lira in fines, Anadolu said. It names 111 defendants, including 13 people who are already in custody.

U.S. officials have been cautious on the extradition of Gulen, saying they need clear evidence. He has lived in self-imposed exile in Pennsylvania since 1999.

Western criticism of the purge and Ankara’s demands that the United States send Gulen home have already frayed ties with Washington and the European Union, increasing tensions over an EU deal with Turkey to stem the flow of migrants.

In another tense exchange, Turkey lashed out at Germany on Wednesday, saying allegations in a media report that Turkey had become a hub for Islamist groups reflected a “twisted mentality” that tried to target Erdogan.

Incensed over a perceived lack of Western sympathy over the coup attempt, Erdogan has revived relations with Russia, a detente Western officials worry may be used by both leaders to pressure the European Union and NATO.

Measures in Wednesday’s decrees will also enable former air force pilots to return to duty, making up for a deficit after the dismissal of military pilots in the purge.

Turkey declared a three-month state of emergency on July 21, and decrees since then have dismissed thousands of security force members and shut thousands of private schools, charities and other institutions suspected of links to Gulen.