The word “coup” in French literally means “blow” or “shock.” The latter meaning aptly describes the reaction of the world to the events in Turkey on the night of July 15-16 by elements of its military.

The circumstances of the coup attempt are still far from clear. What is clear is that its failure owes a great deal to the spontaneous reaction of ordinary people who flooded the streets to resist the military and the solidarity across the political spectrum. All four of the main political parties united in opposition to the attempt to overthrow the democratically elected government. According to the Turkish government, 246 people were killed amid resistance to the coup, 179 of them civilians, and 2,000 were wounded.

But after the shock has come a second blow as the government unleashed a purge that goes far beyond holding to account those involved in trying to overthrow it. It has hit most of the country’s major institutions– the judiciary, prosecutors’ office, police, the media, the civil service, schools, universities, trade unions and hospitals.

This second blow is weakening the democracy that Turkey’s population took to the streets to defend. Turkey’s international partners should act quickly to press Ankara to reverse course and ensure that people caught up in the purge are given due process and fair criminal trials and that the country’s institutions are strengthened rather than weakened.

More than 40,000 people have been dismissed from their posts, including the forced resignation of the heads of every university in the country. The justice system has been particularly hard hit with 2,167 judges and prosecutors jailed and 2,745 removed from their posts. Arrest warrants have been issued for almost 90 journalists since July 25. On July 27, the government closed down three news agencies, 16 television channels, 23 radio stations, 45 newspapers, 15 journals, and 29 publishing houses and distribution companies.

Equally troubling have been the steps to set aside checks on the exercise of executive power. The government has declared a state of emergency that permits the executive to rule by decree with minimal oversight from parliament and none from the constitutional court. It has told the Council of Europe that it is temporarily imposing extraordinary limitations on the European Convention of Human Rights (its duty to prevent and punish torture is unaffected).

The first emergency decree issued by the government, on July 23, underscored its ambition to act without restraint. It orders the closure without any due process of thousands of private educational institutions, hospitals, clinics, and associations. The decree allows the permanent discharge of judges, prosecutors, and civil servants without any investigation or possibility of legal challenge.

The first decree also extends police powers to detain some suspects for up to 30 days without being taken before a judge and seriously curtails the right to private communications with lawyers for those who are placed in pretrial detention, increasing the risk of ill-treatment and undermining the right to an effective defense. A second decree on July 27 permits prosecutors to restrict a detainee’s access to a lawyer for the first five days of police detention. Evidence is already emerging that military officials and others arrested in connection with the coup have been subject to torture or ill-treatment in custody.

What ties together much of this action is that it is targeted against people who are allegedly linked to a movement inspired by Fethullah Gulen, a US-based cleric the government has publicly blamed for the attempted coup. The movement, which runs a network of schools in Turkey and other countries, historically had close ties to the ruling Justice and Development Party (AKP).

Whatever the merits of the government’s claims about the movement’s role in the coup, which Gulen himself denies, the speed and scale of the dismissals make it clear that many of those affected by the purge are caught up in it not because there is clear evidence of their involvement in the coup but merely because of their perceived association with the Gulen movement.

The EU enlargement commissioner Johannes Hahn commented on July 18 that it appears that at least some of the lists the government used had been prepared before the attempted coup even took place.

While the government has the right to pursue criminal and employment proceedings against individuals who support its violent overthrow and particularly those responsible for killing civilians, democracy and the rule of law require those proceedings to be based on clear evidence, and a fair process, including a right of appeal.

The European Union and United States government, the Council of Europe Commissioner for Human Rights and UN High Commissioner for Human Rights have all urged Turkey to ensure that its response to the attempted coup respects the rule of law. Unfortunately, the Turkish government seems intent on taking a different approach and removing checks on executive power. That was already evident before the attempted coup.

Since the government crackdown on demonstrators during protests in 2013, the government and in particular President Erdogan has sought to consolidate power and remove challenges to the authority of the ruling party.

In the past few years, journalists and media outlets — whether secularist, Gulenist, or pro-Kurdish — that were seen as critical of the government have come under sustained pressure, facing prosecution, dismissal, and closure or forced takeover in the case of TV stations and newspapers. The government should protect media freedom, allowing journalists to report and news organisations to operate freely.

The government has responded to concerns about Gulenist influence in the justice system not by reinforcing judicial independent but by consolidating its own control over the courts including by reassigning, dismissing and prosecuting judges and through legislation that brings the main judicial oversight body under greater government control.

The government has labelled the Gulen movement a terrorist organization. That, together with the governments influence over the courts, allows it to apply the full force of Turkey’s overbroad terrorism laws against suspected Gulenists. Reform of terrorism laws and strengthening judicial independence should be priorities.

A similar approach has been used in response to the rising popularity of the peaceful pro-Kurdish Peoples’ Democratic Party (HDP) after it won 13 percent of the vote in the June 2015 general election and seats in parliament. The government has sought to conflate the party with the armed Kurdistan Workers’ Party (PKK), lifting the parliamentary immunity for Peoples’ Democratic Party members and seeking to prosecute those who peacefully advocate the rights of Kurds as though they were members of a terrorist cell plotting violence.

Despite all of the challenges faced by Turkey in recent years, many of them self-inflicted, the popular and political response to the coup attempt was a reminder of the commitment to democracy among most people in Turkey today. It is vital for Washington and Turkey’s other international partners now to use all their influence to press Ankara to reverse course, to safeguards the rights of those caught up in the purge, and to strengthen rather than weaken the independence of the institutions that underpin it, including the courts, media, universities and parliament itself. The people who died defending it deserve nothing less.