President Trump’s shocking ban on travel to the US from seven mostly-Muslim countries has been halted, temporarily. After a burst of lawsuits across the country, a judge in Washington state suspended the ban nationwide on Friday until the matter could be heard properly in the courts. In response, Trump heaped vitriol on the judge and the entire US legal system, referring to the opinion of “this so-called judge” and blaming him for any future terrorist attacks that might occur.

This assault on the impartial and apolitical legal system is something we have seen before, in Britain. When the High Court ruled in November that Theresa May could not trigger Article 50 without parliamentary approval, the judges involved were notably labelled “enemies of the people”. Trump and his surrogates are using the same tactics now, bandying claims of “judicial activism” and accusing the judiciary of blocking the “will of the people”. They are wrong. The issue before the courts is not to what extent the travel ban is good policy, but whether the president has the power to unilaterally change the terms of US visas and alter immigration policy on religious grounds without consulting Congress or the relevant federal agencies. And the answer is no.

The US has a constitution to which all subsequent laws must adhere. It is the foundation of American democracy. The attorneys from the two states that challenged Donald Trump’s travel ban argued that his executive order was unconstitutional, due both to the rushed way it was enforced, denying those affected of due process, and to the religious discrimination it instructed against Muslims. Federal Judge James Robart found that these challenges were likely to succeed, and so suspended the ban until it could be resolved in the courts. Far from “judicial activism”, this is the entire point of a legal system. In any functioning democracy, the judiciary plays a crucial role in interpreting and enforcing the law, and, if necessary, in holding an over-zealous executive in check.

Judge Robart was not making a judgement on foreign policy or on Trump’s administration. He was defending US law from a president who was trying to enact something unconstitutional, and protecting the victims of an illegal executive order. The federal appeals court which upheld Judge Robart’s suspension until legal briefs could be filed was doing the same. If the new administration truly wishes to go forward with the travel ban, they must find a way to do it that is not in conflict with the constitution and existing laws, and not try to circumvent the legislature.

Detractors of so-called “judicial activism” ran up against the same absence of logic when they attacked the British legal system for the Article 50 rulings. Our constitution may be unwritten, but we have the same tradition of turning to a robust judiciary to rule on the legality of government proposals. Simply put, Parliament makes laws; leaving the EU requires a change in the law; and both our High Court and Supreme Court therefore ruled that the government needs parliamentary approval in order to trigger Brexit. The High Court judges were not trying to reverse the result of the referendum or block Brexit – they were reminding Theresa May’s government of the limits of its power. A referendum, whatever the result, does not supersede centuries of constitutional precedent, and the fact that the judges ruled in favour of the law had nothing to do with their own personal feelings on the EU.

Trump, like the extreme Brexiteers after the Article 50 rulings, is enraged that he must work within the confines of the legal system. His anger is both misplaced and dangerous. There has been a fundamental misconception on both sides of the Atlantic that, when a judge rules against a politician, they are stepping out of line and obstructing democracy. That argument takes no heed of the checks and balances on power. In neither the US nor UK system does the executive have the unbridled authority to act in any way it chooses – presidents and prime ministers are bound by the law, as are we all. Judges have not only a right but a duty to block measures they rule (with their extensive legal expertise) go against the law. America’s Founding Fathers, responding as they were to a dictatorial king, wanted a built-in defence against an overreaching executive branch. That’s what the judiciary was for, and right now they are needed more than ever.

It’s not judicial activists we need to worry about, but power-hungry populists with no respect for the law.