As I write, the opening rounds are being staged of what is shaping to be one of the great battles of Western civilisation: President Donald Trump's Muslim ban. I'm not being hyperbolic, trust me.

Four federal judges (as of Monday) have issued temporary injunctions restraining the US government from carrying out aspects of the Trump plan to reshape America by inserting a "Do not" in the statement engraved on Lady Liberty's base. The words are worth repeating, to remind us just how far down the path of fascism the first week has taken America:

"Give me your tired, your poor, your huddled masses yearning to breathe free, the wretched refuse of your teeming shore. Send these, the homeless, tempest-tossed to me, I lift my lamp beside the golden door!"

Trump's ambiguous executive order targeting Muslims in the ostensible name of national security has created utter mayhem but, ironically, created a point of focus for those opposed to his egomaniacal attempt at autocracy. There are real victims and real suffering from this executive act; the bright forces of egalitarian America have awakened and they're itching for the fight.

The mass protests, taxi drivers' strikes and complaints from foreign governments (not Australia, obviously) will have impact in threatening Trump's self-image as the popularly loved Great Leader, but the real fight here will be waged by the US courts.

One of the principal weapons being wielded already -- and this will happen a lot as the courts combat Trump's attempts to extend his executive power way beyond precedent -- is the ancient device called habeas corpus. Nice to see that term being flung around in the media with as much frequency as "alternative facts", but how many pundits know what it actually means? Well, in a rule of law-based democracy, it means pretty much everything.

[Turnbull can't stay silent on Trump forever]

In the first case filed against the Trump immigration decree, the main relief sought on behalf of Hameed Darweesh and Sameer Alshawi (both Iraqi holders of special US visas related to services they had performed for the US military, and both detained on arrival at New York's JFK Airport) was a "Writ of Habeas Corpus to release [them] forthwith".

A writ is a type of court order. Technically, the full form is "habeas corpus ad subjiciendum", which literally translates as "you may have the person for the purpose of subjecting him/her to examination". Practically, it means "produce the body". Courts use habeas corpus to order that a person, who is being held in detention or otherwise having their liberty constrained, is either brought physically before the court, or released altogether.

Habeas corpus is, when you boil everything down, the most important legal protection citizens of a free society possess. It's ancient, predating Magna Carta but enshrined by it. Historically, it was developed as a necessary counter to the eternal tendency of those in authority to exceed their power and infringe the liberties of citizens.

The fundamental principles here are two: that we are free to do as we please, provided we don't break the law or infringe the rights of others; and that public authorities, by contrast, have no freedom at all, rather their powers are only those which the law explicitly gives them. In the conflict between personal freedom and communal interests, the individual has the upper hand. Society (through its government) can only impinge on our freedom by making and enforcing laws strictly within their limits.

Originally, habeas corpus was ordered in the name of the king against his over-reaching subordinates. Magna Carta and the great battles for parliamentary supremacy that followed, were triggered by the king's insistence on exercising his sovereign right to do whatever he wanted, including imprisoning and sometimes beheading people he didn't like. After much trouble including a civil war, it was established that he, too, sits beneath the law.

The arbiters of the law are the courts. The most important development of Western democracy has been the placement of the independent judiciary at the effective peak of government, superior to both executive (Queen or President) and parliament. This applies to the US, which inherited the English common law.

Habeas corpus is the pointy end of the courts' stick. If you find yourself detained or held incommunicado by overly zealous officers of the law, you have the right to petition the court to order your physical production or release. It's not discretionary; if the authority holding you can't prove that it has the legal power to do so, then the court must order your release.

The modern relevance of this remedy is exemplified by the M.V. Tampa. In 2001, the Tampa picked up 433 asylum seekers whose boat had sunk. The Australian government refused them entry into our waters. When the ship did so anyway, the military boarded it and took control.

Justice Anthony North of the Federal Court ordered habeas corpus in favour of the asylum seekers, on the basis that they were being detained by the government without legal power. The appeal court found that the government did have the power, but the principle remains.

[What Donald Trump learned from Australian border policy]

In the cases now pending in the US, the same question will be addressed. Habeas corpus is part of US law, expressly recognised by the US constitution, in which the suspension clause (article 1, section 9) states that: "The privilege of the writ of habeas corpus shall not be suspended, unless when in cases of rebellion or invasion the public safety may require it."

The people being detained at US airports seek habeas corpus on the legal basis that their liberty is being arbitrarily withheld, on no proper legal authority. Ultimately, this will end up in the Supreme Court in an argument about whether Trump's executive order is an unconstitutional overreach of the President's powers. In the meantime, the courts can use habeas corpus to force the release of visa holders (for example), or effectively prevent their forcible return to their countries of origin.

I see this brewing fight as essential viewing. The US courts have never taken a backward step in asserting their supremacy over the other branches of government. As the Supreme Court said in the case of Boumediene v Bush, when it declared that Guantanamo Bay prisoners had a right to habeas corpus:

"To hold that the political branches may switch the Constitution on or off at will would lead to a regime in which they, not this Court, say what the law is."

Trump, it is very clear, does not entertain rejection in any context. There's no reason to think he'll hesitate to take on the courts if they thwart him. No previous president has challenged the supremacy of the courts; if Trump does so, the outcome of this battle will determine the fate of America and much else besides.