Taking on Trump: Is the US facing a constitutional crisis?
Donald Trump says he is defending the United States from terrorism - but a "so-called judge" is "making the job very difficult".
But the judge - in halting the president's controversial executive order on immigration - said he was making sure President Trump's actions follow the law.
That sets two theoretically equal branches of the government against one another - and could bring about a crisis.
What's at stake?
The separation of powers is crucial to understanding how the US is governed.
The country's constitution established its treasured system of checks and balances - where the different branches of government hold equal authority and offset one another.
The federal government's power is split into three distinct parts - the executive branch, which includes the president and his cabinet; the legislative branch, Congress, which makes the laws; and the judiciary.
This works well most of the time, with each branch co-operating with the next.
But with the president in open conflict with another branch, there are fears that an impasse could be reached.
That could lead to a constitutional crisis - a scenario in which the situation cannot be resolved - particularly after Mr Trump seemed to openly question the judge's authority.
"The President's hostility toward the rule of law is not just embarrassing, it is dangerous," Democratic Senator Patrick Leahy, from the Senate judiciary committee, said.
"He seems intent on precipitating a constitutional crisis."
Is a judge really the equal of the president?
There are about 700 federal district judges in the US - the type facing down the president's order.
Unlike state court judges, these men and women are part of the federal court system - along with the Supreme Court and the Courts of Appeals.
Day to day, it's the 94 District Courts which deal with interpretation of US laws, treaties, and public officials - powers devolved to them from the Supreme Court.
But the courts do not offer opinions on government policy unless they are asked - they only interpret law when a case is brought before them.
The other two branches of government make and enforce the laws, and the judicial branch interprets the laws when there is a dispute.
That is the issue here - a presidential executive order has all the force of law, and is subject to the same checks.
- Is Trump's immigration order legal?
- Trump border policy: Who's affected?
- What if Trump tries to bring back torture?
Those judicial powers have been used many times before.
Barack Obama faced stumbling blocks in 2015 when he attempted to use an executive order to grant a reprieve to undocumented immigrants, and George W Bush faced similar battles over detainees in Guantanamo Bay.
Why doesn't Trump fire these judges?
It is true that district judges are appointed by the president and confirmed by the Senate.
Judge James Robart, for example - the "so-called judge" of Mr Trump's Twitter criticism - was appointed by President George W Bush and confirmed in 2004.
But Mr Trump can't fire judges.
That's because the founding fathers of the United States created a system to protect the judiciary from interference.
Only Congress can remove a federal judge from office through impeachment, which involves both the House and Senate. It is the same system used to remove a president.
This "article three" protection is, in practical terms, very rigid. Only eight judges have been convicted in an impeachment trial in the entire history of the United States.
The end result is that federal judges usually serve until they choose to retire - or until death.
In effect, two of the country's three branches of government are in conflict - and neither can remove the other.
What about the Supreme Court?
The Supreme Court, as the name implies, has ultimate power in the judiciary - the other courts are inferior to it.
In this case, the government could have taken its appeal against the district rulings straight to the Supreme Court - and may still do so.
The Supreme Court
of the United States
seats make up the court
Four were appointed by Democrats: two by President Clinton, and two by President Obama
Four were appointed by Republican Presidents: George W Bush, George Bush Snr, and Ronald Reagan
One seat is vacant following the death of Antonin Scalia.
Just as with the other federal courts, though, the Supreme Court is protected from interference.
But there are currently only eight judges on the Supreme Court.
Four were appointed by a Democrat, and four by a Republican - with one vacant seat waiting to be filled by Mr Trump's nominee, which could swing the balance of power.
What about the third power - the legislative branch?
Congress could break any deadlock that crops up between the president and the judiciary by creating a law that overturns his decision - or even impeaching a president or judge.
Since Mr Trump's Republican party holds a majority there, action against the president seems unlikely.
And the independence of the courts is so essential to the US way of governing, that moving to attack judges on behalf of the president would be a drastic step.
Nonetheless, with two of the three powers in conflict, the decision may fall to Congress eventually - unless Mr Trump modifies his order.
That may be the most prudent move, in keeping with his predecessors who have often backed off in the face of judicial opposition.
For now, though, Mr Trump "just cannot believe a judge would put our country in such peril" - and shows no signs of changing his mind.