Trump reacted by tweeting that the Supreme Court "doesn't like me?" But in the end, it was a conservative judge who tipped the balance.
The US Supreme Court on Thursday quashed President Donald Trump's bid to rescind a program that protects young immigrants from deportation.
Conservative Justice John Roberts sided with four Supreme Court liberals to produce a 5-4 vote upholding lower court decisions that Trump had been procedurally "capricious" toward the Deferred Action for Childhood Arrivals (DACA), created in 2012 by his Democratic predecessor Barack Obama.
It protects around 650,000 immigrants who were raised in the US without legal immigration status, known as "Dreamers." The ruling means they will be eligible to obtain renewable two-year work permits.
On the Senate floor, Republican Tom Cotton of Arkansas labelled DACA as illegal and demanded that Chief Justice Roberts "resign."
Welcoming the stay, Democratic leader Chuck Schumer said he "cried tears of joy," adding he felt for "these kids, these families… and I think all of America does."
DACA enrolee Wendy Larios, 19, currently studying nursing and psychology in Bakersfield, California said: "I felt tears of relief running down my face" as the Supreme Court decision emerged.
"It's a great surprize," said Daniel Olano, a 28-year-old Virginia resident who arrived from El Salvador at the age of eight. "My family and I were expecting the worst."
'Shotgun blasts,' says Trump
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."
"We need more Justices or we will lose our 2nd Amendment [on carrying arms] & everything else," he said, adding: "Vote Trump 2020!"
Biden would make DACA permanent
Presumed Democratic presidential rival Joe Biden pledged, if elected, to send Congress proposed legislation to make DACA protections permanent.
Former Democrat president Barack Obama tweeted Thursday: "Eight years ago this week, we protected young people who were raised as part of our American family from deportation."
"Today, I'm happy for them, their families, and all of us," wrote Obama.
Thursday's ruling follow a Supreme Court rebuke Monday declaring the illegality of firing gay and transgender workers and insisting they are protected under US federal employment law.