John Roberts, chief justice of the US supreme court, has chastised Donald Trump for calling a judge who ruled against his migrant asylum order an “Obama judge”.

It is the first time that the leader of the federal judiciary has offered even a hint of criticism of the president, who has previously blasted federal judges who ruled against him.

Ivanka's emails: sins of the daughter threaten to hit Trump where it hurts Read more

“We do not have Obama judges or Trump judges, Bush judges or Clinton judges,” Roberts, a conservative who was appointed by Republican former president George W Bush, said in a statement released by the supreme court on Wednesday.

Sign up for the new US morning briefing

“What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them. That independent judiciary is something we should all be thankful for.”

Trump had taken aim at US district judge Jon Tigar in San Francisco, who on Monday temporarily blocked an order by the Republican president that barred asylum for immigrants who enter the country illegally from Mexico, the latest courtroom defeat for Trump on immigration policy. Tigar was appointed by former president Barack Obama, a Democrat.

Trump responded to Roberts’ criticism in tweets on Wednesday, insisting that so-called “Obama judges” do “have a much different point of view than the people who are charged with the safety of our country”.

“Sorry Chief Justice John Roberts,” he said on Twitter, insisting that cases opposing his policies are disproportionately filed in the ninth circuit court of appeals, the same one that blocked the asylum rule.

“Please study the numbers, they are shocking. We need protection and security – these rulings are making our country unsafe! Very dangerous and unwise!” he wrote.

Before Trump, it had been highly unusual for presidents to single out judges for personal criticism. And a chief justice’s challenge to a president’s comments is unprecedented in modern times.

Last year, the president used the term “so-called judge” after the first federal ruling against his travel ban on people from several Muslim-majority countries.

But Roberts and the high court find themselves at an especially stressful moment. In the aftermath of Trump’s appointment of Justice Brett Kavanaugh, several justices have spoken out about judicial independence and the danger of having the court viewed merely as a political institution divided between five conservative Republicans and four liberal Democrats.

Roberts is widely seen as the justice closest to the middle and likely to determine the outcome of high-profile cases that split the court.

Trump signed a proclamation on 9 November declaring that people who crossed the border between official US ports of entry would be ineligible for asylum. The move was among the most audacious in the administration’s anti-immigrant agenda as federal laws enshrine the right to claim asylum irrespective of how an individual enters the country. The president had cited a threat to national security amid heightened rhetoric on a number of migrant caravans heading towards the US.

But in his ruling on Monday evening, Tigar said Trump did not have the authority to override the current legislation. He also ruled the president had misused his authority to issue emergency regulations and waive a 30-day waiting period to consider comments on the policy change.