Turkey said on Wednesday that it would empty its prisons of tens of thousands of criminals to make room for the wave of journalists, teachers, lawyers and judges rounded up in connection with last month’s failed coup.

The startling decision to put so many criminals convicted of nonviolent offenses back on the streets is a measure of the strains on the state as President Recep Tayyip Erdogan expands a wide-ranging purge of those suspected of being enemies of the government. The efforts have created gaping holes in government institutions, the judiciary, schools, the news media and countless other professions.

Acting under powers granted by a state of emergency and allowing the state to bypass Parliament to enact new laws, Turkey said in a decree issued on Wednesday that it would begin releasing up to 38,000 prisoners, or roughly one in five people behind bars. Most will be freed by the end of the week.

The government has blamed the coup attempt, which unfolded the night of July 15 as a rebel faction of the military sought to topple the government, on Fethullah Gulen, an Islamic cleric who lives in self-exile in rural Pennsylvania and whose followers have long filled positions in state institutions, including the military. But the state has gone well beyond arresting only the military officers suspected of planning the coup attempt.