A panel of the U.S. Court of Appeals for the Third Circuit in Philadelphia recently issued an unprecedented opinion that undermines a fundamental mechanism of checks and balances and poses a broad threat to civil liberties.

In Castro v. U.S. Department of Homeland Security the court refused to allow women and children fleeing violence in Central America and being detained by the immigration authorities in Berks County, to seek writs of habeas corpus challenging the legality of the government's plans to remove them from the country.

Habeas corpus is simply the name for the procedure by which a court investigates the government's justification for depriving someone of liberty. But it is far more than a legal term. In Anglo-American legal and political history, it is celebrated as the "Great Writ of Liberty," and the Constitution specifically guarantees its ongoing availability.

The reason is straightforward. The availability of habeas corpus means that - regardless of the unpopularity of the group to which he or she belongs - an individual at odds with the political branches has access to judicial review by an independent court. In hearing and adjudicating the individual's claim, the court enforces the rule of law.

That is why the Supreme Court held in Boumediene v. Bush that foreigners whom the United States had imprisoned at Guantanamo in pursuit of its campaign against terrorism were entitled by the Constitution to bring habeas cases in federal court even though congressional legislation specifically provided the contrary and the president argued vigorously that judicial review would put national security at risk.

As the court explained, the "judicial authority to consider petitions for habeas corpus relief" and enforce "freedom from arbitrary and unlawful restraint" derives from the separation of powers and "must not be subject to manipulation by those whose power it is designed to restrain." Habeas corpus embodies the "duty and authority" of the judicial branch to ensure that the other branches act lawfully.

But, according to the Third Circuit, the Constitution does not give asylum-seekers detained in Leesport by immigration authorities the same right to be heard in court as alleged terrorists imprisoned in Guantanamo by the armed forces. The refugees, Castro explains, entered the country illegally and were quickly apprehended. Therefore, according to the court, even though they have now been held in Berks County for almost a year, under the immigration statutes they haven't really arrived here at all.

Regardless of how Congress chooses to label these mothers and children, they are still entitled to a judicial forum. The constitutional protection of habeas corpus forbids Congress from denying people on our soil access to the courts by legislatively announcing that they are not here. Permitting such legerdemain would leave the writ "subject to manipulation by those whose power it is designed to restrain."

The Third Circuit's closing of the courtroom doors is contrary not only to what the Supreme Court wrote in Boumediene in 2008 but also to what it did in United States v. The Amistad in 1841.

In 1839, free Africans wrongfully held captive aboard the Spanish ship Amistad killed two crew members and ordered the survivors to sail for Africa. Instead the sailors secretly guided the vessel to New England, where the Africans were immediately taken into federal custody. Spain claimed that they were slaves and insisted that they be handed over forthwith to face execution for piracy and murder.

Citing pressing imperatives of international relations, the executive branch supported this demand. It argued that the prisoners - men, women, and children alike - should be immediately returned to Spain without any federal court investigation. Opposing this position in the Supreme Court, former President John Quincy Adams inquired indignantly, "Is there a law of habeas corpus in the land?"

Adams warned the court that it faced a challenge to "the power and independence of the judiciary itself." If the president could act without review in "the case of Africans," he could do the same "in the case of American citizens."

In The Amistad, the court rejected the executive's position. Observing that "all foreigners" were entitled to "contest their claims before any of our courts," it held that the evidence presented by the government did not establish the Africans' status as slaves and ordered their release.

After this victory, the Africans - who had entered the country without papers, been immediately detained, and remained here in defiance of the government's wishes - lived and spoke freely in various states until they returned to Africa at a time of their choice.

They were lucky that they landed in New Haven in 1839 and not Philadelphia in 2016.

The women and children reaching America today after a desperate flight from dangers abroad deserve a judicial hearing. But the most important reason why the Third Circuit decision should be reversed goes far beyond the fate of these particular petitioners.

In guaranteeing the availability of habeas corpus, the Constitution protects us all. So long as we live in a world in which government officials may act in ways that are popular but illegal every one of us has a stake in making sure that an independent judiciary exercises its duty and authority to enforce the Great Writ of Liberty.

Eric M. Freedman, the Siggi B. Wilzig distinguished professor of constitutional rights at Hofstra Law School, joined an amicus brief in support of the petitioners in Castro. Eric.M.Freedman@hofstra.edu