This post is the latest installment of our “Monday Reflections” feature, in which a different Just Security editor examines the big stories from the previous week or looks ahead to key developments on the horizon.

As Europe reels in reaction to the terrorist bombings in Brussels, amid warnings of future attacks, one thing is certain: Government officials on both sides of the Atlantic will respond with proposals to abandon basic principles of civil liberties and human rights. After the Paris attacks in November 2015, French President François Hollande declared war and imposed a state of emergency that remains in effect to this day. After the Brussels attacks, Senator Ted Cruz recommended patrolling all Muslim neighborhoods in the United States, and Donald Trump urged torture of suspected terrorists.

The pattern is all too familiar. We saw it in the US in World War I, when anti-war protestors were jailed for years; in World War II, when 110,000 US citizens and residents of Japanese descent were interned; and after the September 11, 2001 attacks, when thousands of Arab and Muslim men with no connections to terrorism were nonetheless detained, and many deported. In hindsight, we recognize that government officials overreacted and unjustly trampled on political freedoms and rights. But how do we restore some sense of balance in the wake of terrorist attacks?

It’s been nearly 15 years since 9/11, and the US is still engaged in practices of questionable legality. Nearly one hundred men are still detained at Guantánamo, the Obama administration regularly employs armed drones to kill suspects in faraway places by remote control, and the NSA continues to collect massive amounts of data about the private lives of wholly innocent persons.

At the same time, it’s important to acknowledge that the situation has improved dramatically. And indeed, it did so even before President Obama succeeded George W. Bush. By the time Bush left office, his administration had released over five hundred men from Guantánamo, transferred all detainees out of the CIA’s secret prisons, suspended its use of torture as an interrogation tool, halted extraordinary renditions of terrorism suspects to countries for purposes of torture, afforded Guantánamo detainees access to lawyers, and placed its previously unilateral and warrantless wiretapping program under judicial supervision. And none of these measures were undertaken pursuant to court order.

What, then, brought about these changes? We know from their memoirs that neither President Bush nor Vice President Dick Cheney has any regrets about the measures they put in place after 9/11. Yet by the time they left office, they had significantly curtailed or abandoned nearly all of them. In my new book, Engines of Liberty: The Power of Citizen Activists to Make Constitutional Law, published this week by Basic Books, I ask what led the Bush administration to reform substantially its counterterrorism practices My answer: the credit lies with civil society, as much if not more than the separation of powers, judicial review, and the formal checks and balances of constitutional government.

When civil liberties and human rights groups formulated their initial responses to the “war on terror,” they had little reason for optimism. Michael Ratner of the Center for Constitutional Rights, who filed the first habeas petition challenging Guantánamo detentions, Rasul v. Bush, told me he considered the case “completely hopeless.” And for good reason. As a matter of history, presidents had been free to do whatever they deemed necessary to respond to national security crises, especially concerning “the enemy” or their supporters. The Supreme Court sustained the criminal convictions of anti-war protesters in World War I and the internment of Japanese Americans in World War II, and did not intervene to protect the rights of suspected Communists in the Cold War until after the Senate had censured Joe McCarthy and McCarthyism was on the wane. The “steel seizure case,” Youngstown Sheet & Tube Co. v. Sawyer, is notable principally as the exception that proves the norm, and in any event involved domestic labor relations, not the president’s power to deal with “the enemy.” The closest precedent on point to the Guantánamo case was Johnson v. Eisentrager, which had denied habeas jurisdiction to German prisoners of war in World War II. And the Supreme Court that heard the first Guantánamo case was no foe of the Bush administration; indeed, it had installed Bush in office by blocking the Florida recount in the 2000 presidential election.

Yet to nearly everyone’s surprise, the Supreme Court ruled that the Guantánamo detainees had a right to judicial review of the legality of their detentions — initially, in Rasul, on statutory grounds, but four years later, in Boumediene v. Bush, on constitutional grounds, after Congress had expressly denied habeas jurisdiction to the detainees. What explains these decisions? In my view, the results were driven more by forces outside the Court than by the arguments presented to the Court.

Doctrine certainly did not dictate the outcome in either case. The Court in Rasul relied principally on a statutory argument that the petitioners barely advanced. And Boumediene marked the first time in the Court’s history that it extended constitutional rights to foreign nationals outside our borders. But by the time the Court decided the cases, a variety of initiatives outside the Court had framed the disputes as pitting the rule of law vs. lawlessness — and given that choice, it’s not so surprising that the Court chose the rule of law.

Some of the most important work involved transnational advocacy, designed to bring pressure to bear on foreign governments, so that they would in turn lobby the Bush administration for change. Clive Stafford Smith of Reprieve, a UK-based organization, worked with Ratner and Gareth Peirce, a legendary British defense lawyer, to bring attention to the plight of the British detainees held at Guantánamo. They filed a hopeless habeas suit in the UK, in which a British court, while understandably denying relief as it had no authority over Guantánamo, nonetheless expressed grave concern lest the detainees be deprived of all judicial review, essentially encouraging the US courts to exercise jurisdiction. Stafford Smith and Peirce objected to the kangaroo-court process the Bush administration proposed to use in a military trial against one of their clients. They generated constant press coverage, and ultimately created so much public pressure that Prime Minister Tony Blair had to reverse his initial pro-Bush position and demand the British detainees’ return. Shortly thereafter, three British detainees, known as the “Tipton Three,” became the first to be released from Guantánamo.

Upon their release, Gareth Peirce worked with the Tipton Three to recount the abusive treatment they suffered at the hands of their captors, offering graphic depictions of torture and cruel interrogation tactics. The British press covered these accounts in detail just one month before the US Supreme Court heard oral argument in Rasul. Even though Rasul itself had nothing to do with torture, at oral argument, Justice Ruth Ginsburg specifically asked about it. Paul Clement, representing the administration, assured the Court that the US doesn’t torture. That very week, The New Yorker and CBS’s 60 Minutes II published the photographs of prisoner abuse from Abu Ghraib, depicting many of the practices the Tipton Three had described suffering at Guantánamo.

Stafford Smith and Reprieve repeated this tactic in the countries of origin of many of their 85 detained clients at Guantánamo, and ultimately won release of more than 70 of them — not one by virtue of a court order. More broadly, human rights groups worked with foreign governments, officials, and institutions to bring criticism to bear on the Bush administration’s counterterrorism initiatives. Lord Steyn, a former British Law Lord, called Guantánamo a “legal black hole.” More than one hundred members of Parliament filed an amicus brief in the Rasul case. And European institutions and officials harshly condemned the extraordinary rendition program. Over time, these criticisms took their toll. Several former Bush security officials, including Ambassador Dan Fried, NSC and State Department legal advisor John Bellinger, and Matt Waxman, who worked on detainee affairs for the NSC, the Defense Department, and the State Department, told me that the criticism of foreign government criticism played an important part in convincing the Bush administration to curtail many of its practices in its second term. As Fried said, “We were getting beaten up for our unilateral policies all over the world, especially on Guantánamo. We were taking shots every day. … It got in the way of getting anything done.”

Another civil society initiative that helped frame the Guantánamo cases began years before 9/11, in the aftermath of World War II. When the Supreme Court upheld the conviction of Fred Korematsu for failing to report for internment, civil liberties groups refused to accept the decision as final. Japanese American groups and the ACLU advocated for decades to “reverse” the decision in the eyes of history. More than 40 years later, in 1988, President Ronald Reagan signed the Civil Liberties Act, which formally apologized for the internment, and paid reparations of $20,000 to each survivor. When the Supreme Court took up the Rasul case, the Brennan Center for Justice filed an amicus brief on behalf of Fred Korematsu himself, asking the Court not to make the same mistake again. Civil society’s hard-fought historical reversal of Korematsu cannot help but have been on the Justices’ minds as they addressed whether to defer to President Bush’s assertion of unchecked executive power.

In Engines of Liberty, I recount these and many other campaigns, most of them undertaken outside the federal courts, as examples of how executive power was curbed in the wake of 9/11. I argue that especially in times of crisis, when formal checks on executive power are likely to be compromised, those who value civil liberties and human rights must seek out alternative forums for their campaigns. There remains plenty to be critical about in US counterterrorism policy, especially with respect to secret targeted killing of suspects far from any battlefield. But absent work of civil society, we would undoubtedly be much worse off. And when one compares US practices in the first couple years after 9/11 with those in place at the end of the Bush administration, much less today, civil society has much to be proud of.

Precisely because the formal separation of powers is often so anemic in the face of national security crises, human rights and civil liberties groups play a critically important role in preserving constitutional guarantees in this sphere. But the point is a more general one. Engines of Liberty also examines the two most successful domestic constitutional rights campaigns of recent years — that of gay rights groups for marriage equality, and that of the National Rifle Association for an individual right to bear arms. In both settings, citizens with a particular constitutional vision not reflected in existing doctrine worked through associations to lay the ground for constitutional transformation. As with the civil liberties and human rights groups, the lion’s share of the NRA’s and the gay rights advocates’ advocacy took place outside the federal courts. And as with civil liberties after 9/11, so with marriage equality and the right to bear arms, the course of constitutional law and practice was determined more by civil society than by the courts.