The number of people detained by Turkish authorities following the failed coup to oust President Recep Tayyip Erdogan has passed 26,000.

The justice minister, Bekir Bozdag, told the state-run Anadolu Agency that 16,000 of those had been formally arrested and taken into custody while 6,000 detainees were being processed and almost 8,000 suspects remain free but under investigation.

Mr Bozdag did not give details on the status of the remaining 4,000 suspects out of the 26,000 reportedly detained and it was unclear whether any had been released.

Thousands of members of the armed forces, police, judiciary, civil service and public sector have been removed from their posts over alleged links to the Gulen or “Hizmet” movement, which was blamed for the coup.

Turkey's President Erdogan defends government action

Around 50,000 passports were cancelled, journalists and academics have been arrested and more than 130 media outlets were shut down.

Authorities say the attempt on 15 July was staged by a military faction loyal to the exiled Muslim cleric Fethullah Gulen, but it has denied any involvement.

Hundreds of soldiers armed with fighter jets, helicopters and tanks took control of key areas of the capital while Mr Erdogan was on holiday but were defeated after the President flew into Istanbul to make a defiant speech against an “act of treason and rebellion”.

Western governments and human rights groups have condemned the coup attempt, in which at least 246 people were killed and more than 2,000 injured, and also expressed concern over the extent of the crackdown tightening Mr Erdogan’s grip on power.

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

Turkish authorities say Gulen's followers used messaging apps to communicate with each other in the years ahead of the coup attempt, allowing Turkey's national intelligence agency, to identify at least 56,000 operatives in the network since 2014.

“Our assessment is that 150,000 unique operatives used ByLock to communicate with others,” a senior Turkish official said, adding that the group has also used another app called Eagle, which could be disguised as other popular instant messaging apps such as Whatsapp and Tango.

Turkey's Haberturk newspaper reported that the High Council of Judges and Prosecutors has carried out work for another round of purges for 1,500 judges and prosecutors after nearly 3,000 were suspended in the days after the coup attempt.

The country has also been restructuring its armed forces after 1,700 military personnel were dishonourably discharged, including a large proportion of senior generals.

The Director of US National Intelligence, James Clapper, warned that the purges were hampering the fight against Isis by sweeping away Turkish officers who had worked closely with international partners.

People wave Turkey's national flags during the Democracy and Martyrs Rally (Reuters)

Talks over Turkey’s possible accession to the EU have been strained amid the continuing crackdown, with foreign minister Mevlut Cavusoglu threatening to back out of the refugee deal if visa-free travel is not granted and the EU responding with accusations of “blackmail”.

The EU demands that Turkey fulfil a list of criteria including amending its anti-terrorism laws so they cannot be used to target academics, journalists and political dissenters.

Mr Erdogan has accused countries raising concern over the response to the coup of supporting the plotters and targeted Amnesty International for a report alleging that some people detained in connection with the attempt had been tortured.

He insisted that Turkey had a policy of “zero tolerance toward torture” and accused the human rights organisation of ignoring violence committed by plotters during the attempt.