WASHINGTON — Chief Justice John G. Roberts Jr. directed a rare and pointed shot at President Trump on Wednesday, defending the federal judiciary in the wake of Trump’s criticism of an “Obama judge” who ruled against the administration’s attempt to bar migrants who cross the border illegally from seeking asylum.

“We do not have Obama judges or Trump judges, Bush judges or Clinton judges,” Roberts said in a statement released by the court’s public information office. “What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them.”

Delivered on the eve of Thanksgiving, Roberts added: “That independent judiciary is something we should all be thankful for.”

Supreme Court justices, and the chief in particular, almost never issue statements on news events. So it appeared Roberts was eager to counter Trump’s criticism when asked to comment by the Associated Press. The statement did not mention the president.

The chief justice is an aggressive defender of the judiciary, and has frequently expressed worries about attacks on its impartiality, whether they come from the left or the right. He had made it clear last month that he felt the recent partisan battle over the nomination of Justice Brett M. Kavanaugh had cast a shadow on his own court.

At an event at the University of Minnesota just after Kavanaugh’s confirmation, Roberts sought to assure that the court served “one nation” and not “one party or one interest.”

“Our role is very clear: We are to interpret the Constitution and laws of the United States, and to ensure that the political branches act within them,” he said. “That job obviously requires independence from the political branches. The story of the Supreme Court would be very different without that sort of independence.”

Trump on Tuesday had told reporters outside the White House that he was “going to put in a major complaint” against the federal judge who temporarily blocked his administration from denying asylum to migrants who illegally cross the southern border.

U.S. District Judge Jon S. Tigar, who serves in the Northern District of California, ruled late Monday that federal law clearly states that migrants can seek asylum anywhere on U.S. soil.

“Whatever the scope of the President’s authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden,” the judge, appointed by President Barack Obama, wrote in his 37-page ruling.

Trump erupted about the decision. “This was an Obama judge. And I’ll tell you what, it’s not going to happen like this anymore,” Trump said. “Everybody that wants to sue the United States, they file their case in – almost – they file their case in the 9th Circuit. And it means an automatic loss no matter what you do, no matter how good your case is.”

Trump added: “We will win that case in the Supreme Court of the United States.”

Lower courts have not been accommodating to Trump’s efforts to crack down on illegal immigration. They have temporarily blocked Trump’s efforts to strip funding from “sanctuary” cities and rescind temporary work permits and deportation protections from roughly 1 million immigrants who were protected under past administrations.

But the Supreme Court last June upheld the president’s “travel ban” on those from certain Muslim-majority countries, in a 5 to 4 decision written by Roberts. He put aside comments that the president had made about Muslims in ruling that the president had not exceeded his powers.

“The issue before us is not whether to denounce the statements,” Roberts wrote. “It is instead the significance of those statements in reviewing a Presidential directive, neutral on its face, addressing a matter within the core of executive responsibility. In doing so, we must consider not only the statements of a particular President, but also the authority of the Presidency itself.”

He added: “We express no view on the soundness of the policy.”

Roberts has not commented on Trump before, even though during the campaign Trump as a candidate called Roberts a “disaster” because of his vote with the court’s liberals to uphold the Affordable Care Act, more commonly known as Obamacare.

Liberals who follow the court and are often critical of Roberts applauded his Wednesday statement.

“A remarkable rebuke of a President by a Chief Justice – offhand, I can’t think of any historical analogy even close. But then again, every day Trump breaches norms never before breached. Major kudos to Chief Justice Roberts for doing the right thing,” Georgetown law professor Marty Lederman said in a tweet.