Last week, in a public courtroom in the federal courthouse in Seattle, the states of Washington and Minnesota — after suing President Donald Trump, alleging injury caused by his executive order that suspended the immigration of all people from seven foreign countries — asked a federal judge to compel the president and all those who work for him to cease enforcing the order immediately. After a brief emergency oral argument, the judge signed a temporary restraining order, which barred the enforcement of the president's order everywhere in the United States.

The president reacted with anger, referring to the judge as a "so-called judge," and immigrant rights groups praised the judicial intervention as a victory for the oppressed. The president meant, I think, that Judge James L. Robart had not acted properly as a judge by second-guessing him — that he had acted more like a politician; and the immigrant rights groups felt, I think, that the United States was once again a beacon of hope for refugees.

Here is the back story.

A 1952 federal statute permits the president to suspend the immigration status of any person or group whose entry into the United States might impair public health or safety or national security. Trump exercised that authority in accordance with the 1952 law when he signed his Jan. 27 order banning all immigration from the seven named countries.

When the president exercises powers granted to him by the Constitution or federal statues or when Congress passes bills, one cannot simply sue the government in federal court because one does not like what has been done. That is so because the Constitution has preconditions for a lawsuit in federal court. One of those preconditions is what lawyers and judges call "standing." Standing means that the plaintiff has alleged and can most likely show that the defendant has caused the plaintiff an injury in fact, distinct from all others not in the case.

Hence, it is curious that the plaintiffs in the Seattle case were not people whose entry had been barred by Trump's order but rather the governments of two states, each claiming to sue in behalf of people and entities resident or about to be resident in them. The court should have dismissed the case as soon as it was filed because of long-standing Supreme Court policy that bars federal litigation alleging harm to another and permits it only for the actual injury or immediate likelihood of injury to the litigant.

Nevertheless, the Seattle federal judge heard oral argument on the two states' emergency application for a temporary restraining order against the president. During that oral argument, the judge asked a lawyer for the Department of Justice how many arrests of foreign nationals from the seven countries singled out by the president for immigration suspension there have been in the United States since 9/11. When the DOJ lawyer said she did not know, the judge answered his own question by saying, "None."

He was wrong.

There have been dozens of people arrested and convicted in the United States for terrorism-related crimes since 9/11 who were born in the seven countries. Yet even if the judge had been correct, his question was irrelevant — and hence the answer meaningless — because it does not matter to a court what evidence the president relied on in this type of order. This is the kind of judicial second-guessing — substituting the judicial mind for the presidential mind — that is impermissible in our system. It is impermissible because the Constitution assigns to the president alone nearly all decision-making authority on foreign policy and because Congress has assigned to the president the power of immigration suspension as a tool with which to implement foreign policy.

These rules and policies — the requirement of standing before suing and the primacy of the president in making foreign policy — stem directly from the Constitution. Were they not in place, then anyone could sue the government for anything and induce a federal judge to second-guess the president. That would convert the courts into a super-legislature — albeit an unelected, unaccountable, opaque one.

I am not suggesting for a moment that the courts have no place here. Rather, they have a vital place. It is to say what the Constitution means, say what the statutes mean and determine whether the government has exercised its powers constitutionally and legally. It is not the job of judges to decide whether the government has been smart or prudent, though.

One of the arguments made by the state of Washington to explain why it had standing was laughable. Washington argued that corporations located in Washington would suffer the irreparable loss of available high-tech-qualified foreign employees if the ban were upheld. Even if this were likely and even if it were provable, it would not establish injury in fact to the government of Washington. When pressed to reveal what entity Washington was trying to protect, it enumerated a few familiar names, among which was Microsoft.

Microsoft? The government of the state of Washington is suing to protect Microsoft?! Microsoft could buy the state of Washington if Starbucks were willing to sell it.

I jest to make a point. The rule of law needs to be upheld. Carefully paying attention to constitutional procedure protects personal freedom. In similar environments, the late Justice Antonin Scalia often remarked that much of what the government does is stupid but constitutional and that the courts' only concern is with the latter.

The DOJ is now challenging the Seattle restraining order in the 9th U.S. Circuit Court of Appeals, and this case may make its way to the Supreme Court. Will federal judges be faithful to the rule of law? We shall soon find out.

Andrew P. Napolitano, a former judge of the Superior Court of New Jersey, is the senior judicial analyst at Fox News Channel. Judge Napolitano has written seven books on the U.S. Constitution.