Americans understand that the government can't just lock away their friends or neighbors without explanation or giving them a day in court. But should that still be true when we're talking about accused terrorists?

For five years, the executive branch and Congress have said that foreign enemy combatants should not have access to federal courts and have allowed them to languish in a Guantánamo prison without outside judicial review. Last month, US senators narrowly failed to reverse this misguided strategy, but we all have a stake in the consequences of this debate.

At stake is habeas corpus, a doctrine as old as Magna Carta. Its core principle, that no person can be locked away without a fair and impartial court review, is the cornerstone of all free societies, including America's.

Habeas corpus protects all of us by ensuring that government is detaining the right people and not accidentally (or intentionally) jailing the innocent. It allows a fair hearing and nothing more. If a judge finds that imprisonment is lawful, an inmate remains in confinement.

Since 9/11, courts have affirmed that under federal law they may review legal claims of individual detainees. But before those rulings led to habeas hearings, Congress twice voted to change the rules. After the Supreme Court ruled that enemy combatants could file habeas claims in federal courts, Congress last year passed the Military Commissions Act, which prohibits courts from hearing such cases.

Why should Americans protect the rights of people possibly bent on their destruction? There are many reasons, but the main one is this: Championing the rule of law is the best way to protect American society, and its founding values.

We must, of course, aggressively protect the nation's security. But ultimately, the conditions that foster terrorism will recede as systems of justice, and respect for human rights, take greater root around the world. Efforts to advance the rule of law, including those by the US government, are undermined when America is seen as not living up to the values it promotes elsewhere.

Four retired commanding officers of the US Judge Advocate General Corps recently warned Congress that the Military Commissions Act actually increases the risk that US personnel and tourists overseas will be imprisoned without legal review.

Some argue that military necessity makes normal court review for detainees an unaffordable luxury, but they should consider this: Even Israel, which lives in constant threat of deadly attack, ensures a prompt court review of all suspected terrorists. It has found that protecting its values and liberties is key to protecting its safety. In one 1980 case, Kawasme v. the Minister of Defense, Israel's Supreme Court went so far as to say: "There is no more potent weapon than the rule of law."

In our own time of anxiety, that is a powerful example to consider and follow.

If there is one positive to be taken from last month's Senate vote, it is that a majority voted to restore habeas – although still short of the 60 needed to clear a procedural hurdle. Another is that the Supreme Court has affirmed the importance of this issue, deciding that it will review whether the Military Commissions Act's habeas provision is constitutional.

By holding governments accountable, and by preventing wrongful imprisonment, habeas corpus has expanded human safety and freedom for nearly 800 years. Even in risky times – indeed, especially in risky times – that is a value worth preserving, for friends and enemies alike.