ISTANBUL — 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.