Earlier, Chief Justice John Roberts, who rarely makes political statements, rebuked criticism of the courts by Trump, insisting that the judiciary is "independent."
Responding to complaints by Trump that judges appointed by Democratic presidents act against the current White House, Roberts told the Associated Press: "We do not have Obama judges or Trump judges, Bush judges or Clinton judges."
"What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them," Roberts said.
"That independent judiciary is something we should all be thankful for," the chief justice added in a brief statement.
Trump, who is on holiday in Florida, fired back on Twitter.
"Sorry Chief Justice John Roberts, but you do indeed have 'Obama judges,' and they have a much different point of view than the people who are charged with the safety of our country," he wrote.
Sorry Chief Justice John Roberts, but you do indeed have “Obama judges,” and they have a much different point of view than the people who are charged with the safety of our country. It would be great if the 9th Circuit was indeed an “independent judiciary,” but if it is why......
He said that "a vast number" of cases concerning his controversial priorities, like a harsh crackdown on illegal immigration, had been overturned. "Please study the numbers, they are shocking," Trump wrote.
.....are so many opposing view (on Border and Safety) cases filed there, and why are a vast number of those cases overturned. Please study the numbers, they are shocking. We need protection and security - these rulings are making our country unsafe! Very dangerous and unwise!
The row came one day after Trump criticized a federal judge who temporarily blocked the administration from its decision to deny the right to political asylum applications for people who enter the country illegally.
US District Judge Jon Tigar in San Francisco issued a temporary restraining order against the Trump move, which comes as a large group of Central American migrants, frequently described by Trump as dangerous, is heading on foot for the US southern border.
On Tuesday, Trump lashed out at the judge's ruling, calling it a "disgrace."
"This was an Obama judge, and I'll tell you what, this is not going to happen anymore," Trump said. "People should not be allowed to immediately run to this very friendly circuit and file their case."
"We will win that case in the Supreme Court of the United States," Trump said.
Trump has repeatedly attacked the judiciary when cases have gone against him in the past but this was the first time that Roberts, a conservative jurist who was appointed to the nation's highest court by Republican president George W. Bush, has responded publicly.
During the 2016 presidential election campaign, Trump attacked the Mexican-American heritage of a judge who ruled against him in a case involving Trump University.
The US federal government consists of three branches -- the executive headed by the president, the legislative comprising the House of Representatives and Senate and the judicial made up of the courts. The judiciary, especially the Supreme Court, is meant to be above the political fray.
Critics of the Trump immigration crackdown say that by restricting asylum seekers to border crossing points the government is effectively shutting the door on people who may truly be fleeing for their lives.
Trump's administration has argued that he has the executive power to curb immigration in the name of national security -- a power he invoked after taking office last year with a controversial ban on travellers from several mostly Muslim countries.
The final version of the order was upheld by the Supreme Court on June 26 after a protracted legal battle.
Earlier, Chief Justice John Roberts, who rarely makes political statements, rebuked criticism of the courts by Trump, insisting that the judiciary is 'independent.'