The US Supreme Court dealt President Donald Trump's anti-immigration efforts a fresh blow Thursday when it rejected his cancellation of a program protecting 700,000 "Dreamers," undocumented migrants brought to the United States as children.

In the high court's second rebuff of administration policies this week, justices said Trump's 2017 move to cancel his predecessor Barack Obama's landmark Deferred Action for Childhood Arrivals (DACA) program was "arbitrary and capricious."

Chief Justice John Roberts, who sided with the court's liberal members in a five-to-four decision, stressed it was not an assessment of the correctness of the 2012 DACA program itself.

Pro-immigration activists in front of the US Supreme Court after the court upheld the DACA "Dreamers" program offering legal protections to some 700,000 people brought into the country illegally as children
Pro-immigration activists in front of the US Supreme Court after the court upheld the DACA "Dreamers" program offering legal protections to some 700,000 people brought into the country illegally as children AFP / NICHOLAS KAMM

Instead, they said the Trump administration had violated government procedures in the way it sought to quickly rescind DACA in September 2017 based on weak legal justifications.

The ruling suggested there are legal administrative methods Trump could use to cancel DACA, putting the onus back on the administration if it wants to pursue the issue.

US President Donald Trump has sought to expel many of the millions of people living in the United States who entered the country without immigration documents
US President Donald Trump has sought to expel many of the millions of people living in the United States who entered the country without immigration documents AFP / SAUL LOEB

The decision gave a reprieve, though possibly only temporary, to hundreds of thousands of people brought or sent to the United States as youngsters. They grew up here, went to school, worked and started families -- without ever having legal status.

"It was a great surprise," said Daniel Olano, a 28-year-old Virginia resident who arrived in the United States from El Salvador when he was eight.

"My family and I were expecting the worst," he said with relief.

Houston paramedic Jesus Contreras, who came from Mexico as a child, said Thursday's ruling was "not the end of the battle."

Students and supporters of DACA rally in Los Angeles in November 2019
Students and supporters of DACA rally in Los Angeles in November 2019 AFP / Frederic J. BROWN

"We still have to fight for legislation but right now it is a good feeling to know that we are protected and safe at least for now," he said.

Trump was angry after the court, which he has worked to stack with conservatives, dealt him his second legal setback in days.

Target of Trump's ire: the US Supreme Court
Target of Trump's ire: the US Supreme Court GETTY IMAGES NORTH AMERICA / CHIP SOMODEVILLA

On Monday the court ruled that constitutional protections against discrimination on the basis of sex covered homosexuals and transgender people, a position the Trump administration opposed.

In that case conservative Neil Gorsuch, named by Trump to the court in 2017, sided with Roberts and the four liberals in a six-to-three vote.

"Do you get the impression that the Supreme Court doesn't like me?" Trump tweeted.

"These horrible & politically charged decisions coming out of the Supreme Court are shotgun blasts into the face of people that are proud to call themselves Republicans or Conservatives," Trump wrote.

Immigration champions cheered Thursday's ruling.

"Eight years ago this week, we protected young people who were raised as part of our American family from deportation," Obama tweeted.

"Today, I'm happy for them, their families, and all of us. We may look different and come from everywhere, but what makes us American are our shared ideals."

Trump entered office in January 2017 promising to end most immigration and to expel millions who live in the country without legal documents.

Unable to get Congress to agree on legislation to protect long-time resident immigrants, in 2012 the Obama administration turned to an executive order to implement DACA.

It offers people who entered the United States as children and grew up here authorization to stay, attend school, work and enjoy public benefits on renewable two-year periods.

The Supreme Court judgment made clear Trump could end DACA by other means, including an executive order.

It brought new calls Thursday for Congress to pass permanent legislation to help those under DACA, as well as to offer several million more people, including Dreamers' parents, protection from deportation.

Senior Democratic lawmakers Jerrold Nadler and Zoe Lofgren urged the Republican-controlled Senate "to immediately take up and pass H.R. 6, the American Dream and Promise Act, which puts Dreamers and long-term beneficiaries of Temporary Protected Status on a pathway to citizenship. The time to act is now."