Almost 34,000 inmates have been released from prisons in Turkey in a suspected move to free up space for thousands of people detained over a failed coup.

The move appeared to be part of measures announced last month to allow the release of inmates unrelated to the attempt to oust President Recep Tayyip Erdogan.

Those who had served half their sentence were eligible, with crimes such as murder and rape excluded from the scheme.

Analysts suspect the mass release is a move to make room in Turkey’s overcrowded jails to allow the imprisonment of more alleged coup plotters.

Bekir Bozdag, the justice minister, said 33,838 prisoners convicted before 1 July who had demonstrated “good behaviour” were released on Thursday evening.

Turkey’s failed coup strains relations with the West

The United Nations and EU have raised concern over a series of purges and crackdowns following the attempt on 15 July, which sparked the detention of more than 40,000 people.

Those arrested include civil servants and academics accused of supporting the Gulen movement, which authorities blame for the coup, and thousands of public sector workers have been suspended or sacked.

More than 130 media outlets have been shut down, with dozens of journalists detained, while prisoners have reported torture and abuse.

The Office of the UN High Commissioner for Human Rights (OHCHR) warned last month that the purges may violate international law.

“While we understand the sense of crisis in Turkey, we are concerned that the government’s steps to limit a broad range of human rights guarantees go beyond what can be justified in light of the current situation,” experts said in a joint statement.

In pictures: Turkey coup attempt Show all 17 1 /17 In pictures: Turkey coup attempt In pictures: Turkey coup attempt Turkish President Erdogan attends the funeral service for victims of the thwarted coup in Istanbul at Fatih mosque on July 17, 2016 in Istanbul, Turkey Burak Kara/Getty Images In pictures: Turkey coup attempt Soldiers involved in the coup attempt surrender on Bosphorus bridge with their hands raised in Istanbul on 16 July, 2016 Gokhan Tan/Getty In pictures: Turkey coup attempt A civilian beats a soldier after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 REUTERS/Murad Sezer In pictures: Turkey coup attempt Surrendered Turkish soldiers who were involved in the coup are beaten by a civilian Reuters In pictures: Turkey coup attempt Soliders involved in the coup attempt surrender on Bosphorus bridge Getty In pictures: Turkey coup attempt Supporters of Turkish President Recep Tayyip Erdogan wave flags as they capture a Turkish Army vehicle Getty In pictures: Turkey coup attempt People pose near a tank after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 Reuters In pictures: Turkey coup attempt Turkish soldiers block Istanbul's Bosphorus Brigde Getty In pictures: Turkey coup attempt A Turkish military stands guard near the Taksim Square in Istanbul Reuters In pictures: Turkey coup attempt Pierre Crom/Twitter In pictures: Turkey coup attempt Turkish soldiers secure the area as supporters of Recep Tayyip Erdogan protest in Istanbul's Taksim square AP In pictures: Turkey coup attempt People demonstrate in front of the Republic Monument at the Taksim Square in Istanbul Murad Sezer/Reuters In pictures: Turkey coup attempt Turkish soldiers detain police officers during a security shutdown of the Bosphorus Bridge Reuters In pictures: Turkey coup attempt Turkish Army armoured personnel carriers in the main streets of Istanbul Getty In pictures: Turkey coup attempt Chaos reigned in Istanbul as tanks drove through the streets EPA/TOLGA BOZOGLU In pictures: Turkey coup attempt Turkish President Tayyip Erdogan speaks to media in the resort town of Marmaris Reuters In pictures: Turkey coup attempt Supporters of President Erdogan celebrate in Ankara following the suppression of the attempted coup Reuters

“Turkey is going through a critical period. Derogation measures must not be used in a way that will push the country deeper into crisis.”

The amnesty came amid continuing disputes between the Turkish government and EU over a deal struck earlier this year to reduce refugee crossings over the Aegean Sea.

Mr Erdogan said his administration had only received a small fraction of the €6 billion (£5 billion) pledged in support of 3 million refugees Turkey currently hosts.

“What happened? The support given until now is €183 million," he said on Friday.

“And they did not give it to us, they gave it to Unicef. No country can stand alone in this crisis. Unfortunately the promises on this issue are not kept.”