A court in Istanbul has remanded 17 Turkish journalists in custody as international concern mounts over the government’s targeting of reporters.

Twenty-one journalists appeared before a judge in hearings that lasted until midnight on Friday. Four were freed but 17 have been charged with membership of a terror group, the state-run Anadolu news agency said.

Arrest warrants were issued this week for 89 journalists, at least 40 of whom have now been detained. The Turkish government has used a state of emergency law to order the closure of at least 131 newspapers, television and radio stations, publishers and news agencies.

Some of those arrested used to work for the Zaman newspaper, which had close links with the Hizmet movement of the US-based Muslim cleric Fethullah Gülen.

The Turkish president, Recep Tayyip Erdoğan has accused Gülen of helping to organise the coup. Zaman was taken over by government-appointed trustees in March and is now strongly pro-Erdoğan.

Mahir Zeynalov, a Washington-based correspondent for Today’s Zaman, the English language version of the newspaper, has tweeted a series of images of Turkish journalists being arrested on Friday.

Nazli Ilicak, 72 years old veteran of Turkish journalism. A staunch supporter of liberal democracy. Now under arrest pic.twitter.com/UYrVRAncOK — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Veteran journalist Nazlı Ilıcak, 72, is one of the journalists detained.

Bulent Mumay. A hard-working man, who made enemies among Erdogan's inner circle for top-notch journalism. Arrested. pic.twitter.com/h8UXFAsUoR — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

The prominent commentator Bülent Mumay was one of those freed after appearing in court. He was later given a rapturous welcome by supporters.

Emma Sinclair-Webb, the Turkey director at Human Rights Watch, said: “The government crackdown is on media outlets and journalists it accuses of being linked to the Fethullah Gülen movement, which it blames for the foiled military coup.

“In the absence of any evidence of their role or participation in the violent attempt to overthrow the government, we strongly condemn this accelerated assault on the media, which further undermines Turkey’s democratic credentials.”

Amnesty International also condemned the arrests. Its deputy Europe director, Fotis Filippou, said: “Rounding up journalists and shutting down media houses is the latest assault on a media already weakened by years of government repression ... the authorities are intent on silencing criticism without regard to international law.”

In a surprise move, Erdoğan said late on Friday that he would drop all lawsuits brought against people for insulting him. The justice ministry said earlier this year that prosecutors had opened more than 1,800 cases against journalists, cartoonists and even children for insulting Erdoğan since he became president in 2014.

The move could be an attempt to silence his western critics, but it was not clear whether he would also abandon his legal action against the German comedian Jan Böhmermann, who recited a poem on German TV earlier this year suggesting that the Turkish leader engaged in bestiality and watched child pornography.

The poem prompted Erdoğan to file a complaint with German prosecutors that he had been insulted. Members of her own cabinet criticised the German chancellor, Angela Merkel, for acceding to the request from Ankara to prosecute the comedian.

In May, Boris Johnson, now the British foreign secretary, won a competition organised by the Spectator for writing a rude poem about Erdoğan.

The limerick, published by the magazine as a rebuff to Erdoğan’s bid to prosecute the German comedian, jokingly implies that he has sex with a goat.

Johnson, whose great-grandfather was Turkish, called it a scandal that a German court had granted an injunction to prevent Böhmermann repeating his skit.

Ali Bulac. A powerful mind, one of Turkey's rare Islamist sociologists. Refused to bow to Erdogan. Arrested. pic.twitter.com/IRG596pU78 — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Ahmet T. Alkan. He made his point through satire. Was a marvelous novelist. Now with head held high, going to jail. pic.twitter.com/q0B5mYRkky — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Sahin Alpay. I don't know anyone else who fought for Turkish democracy more than him. A champion of rights. Arrested pic.twitter.com/RXH7AselAF — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Mehmet Gundem. Hardly anyone could get away when he asked questions. An interview geek. Arrested. pic.twitter.com/o7f0bdehte — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Cihan Acar. Colleagues called him "cemetery Cihan" for exceptional coverage of funerals, from Kurds to celebrities. pic.twitter.com/oOJrPB8MWA — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Yakup Cetin. We know his face because he was live on TV when a story broke out. As every great reporter, arrested. pic.twitter.com/lvhOgj5JWN — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Bayram Kaya. Made his career by digging into Turkey's economic life. Now under arrest for excellent court reporting. pic.twitter.com/BL1Pbt0Emr — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Hasim Soylemez. A general assignment investigative reporter who wrote about almost anything. Price: Arrested. pic.twitter.com/I0nVq0yySm — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

A talented journalist, unwavering editor. Published a series of court investigations. Now paying the price. Arrested pic.twitter.com/oBhCBKO2AC — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Emre Soncan. To learn anything about the military, he was the reporter to read. Extraordinary journalist. Arrested. pic.twitter.com/DjLqpYrh2u — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Ufuk Sanli. His Al Monitor columns shed light on Turkey's economy. An avid reader, excellent reporter. Arrested. pic.twitter.com/N3ZV4yAVim — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Abdullah Kilic. Supreme irony that he made headlines for investigating 1960 military coup. Arrested on coup charges. pic.twitter.com/jJVILgjRIE — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Ali Akkus. If Turkey has few excellent newsroom editors, he is among the top. Publisher of graft cases. Arrested. pic.twitter.com/uqUQAfFGv6 — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Cemal Kalyoncu. He knew nothing in his life besides reporting and editing. Arrested because he did not bow to power. pic.twitter.com/QrCthaUF9Y — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Busra Erdal. Veteran court reporter. Revered & reviled, made enemies because she never stopped writing. Arrested. pic.twitter.com/oEKAp9o1tO — Mahir Zeynalov (@MahirZeynalov) July 29, 2016

Arda Akin. Known for columns that deeply disturbed the government. Roared when necessary, without fear. Arrested. pic.twitter.com/k7qVvOxsE0 — Mahir Zeynalov (@MahirZeynalov) July 29, 2016