With Chief Justice John G. Roberts Jr. leading the majority, the court ruled 5-4 against the administration. It called the decision to cancel the DACA program arbitrary and unjustified. The program allows young people who were brought to the country as children to register with the government and obtain a work permit if they have clean records.
Immigration activists solidified a major win in the controversial and contentious case that goes back eight years.
RELATED: DACA: Supreme Court blocks President Trump from ending program for immigrants
"Today's Supreme Court ruling on DACA (Deferred Action for Childhood Arrivals) delivers a powerful message: this country and this city belong to Dreamers today. This will remain your home tomorrow,'' Los Angeles Mayor Eric Garcetti wrote on his Twitter page.
Rep. Lucille Roybal-Allard, D-Los Angeles, said the ruling means a sigh of relief for so-called Dreamers, about one-quarter of which are believed to live in California.
"The court has done the right thing and protected DACA recipients from the Trump Administration's arbitrary and capricious effort to destroy the DACA program,'' Roybal-Allard said. "The Obama Administration's creation of DACA in 2012 was a historic step to provide safety and security to hundreds of thousands of Dreamers who call America their only home. When the Trump Administration tried to terminate DACA, that sense of safety and security was ripped away.''
Los Angeles County Supervisor Hilda Solis also said the ruling provides security, at least for now, for "hard-working immigrants.''
"Dreamers embody the values of this country through their work ethic, their optimism and unwavering loyalty to this nation,'' Solis said. "DACA recipients are military veterans, medical students and employees of Fortune 500 companies. Dreamers are our friends, family members, employers and neighbors.''
Rep. Lou Correa, D-Santa Ana, said DACA recipients "have earned the right to the American Dream.''
"They follow the law, contribute to our economy, pay taxes, and many are doctors, nurses, police officers, firefighter, and serve in our military,'' he said. "Our community in North Orange County is home to the largest number of Dreamers in America.''
WATCH: ABC News special report:
Trump blasted the court's action, calling the DACA decision and other recent rulings "shotgun blasts into the face of people that are proud to call themselves Republicans or conservatives.''
"The recent Supreme Court decisions, not only on DACA, sanctuary cities, Census and other, tell you only one thing, we need NEW JUSTICES of the Supreme Court,'' Trump wrote on Twitter. "If the radical Left Democrats assume power, your Second Amendment, right-to-life, secure borders and religious liberty, among many other things, are OVER and GONE.
California led the fight against rescinding DACA, and leaders across the state celebrated the Supreme Court's ruling.
"I believe the Supreme Court's decision today is a true inditement of the way President Donald Trump does his business. We have tried to say that over and over to America in our 84 lawsuits against this administration. That the way Donald Trump does business is not America's way. That the way Donald Trump does business is not according to the rule of law. That the way Donald Trump does business does not reflect American values," California Attorney General Xavier Becerra told Eyewitness News.
Los Angeles County Supervisor Mark Ridley-Thomas said there are about 85,000 DACA recipients in the county, and the court's ruling renews their "hopes and dreams.''
"It reminds us once again of the importance of the checks and balances that have guided our Democracy, especially in the face of an administration that has continually attacked a community that is so vital to every facet of our country,'' Ridley-Thomas said. "... However, even with today's positive news, we must not let our guard down.
RELATED: Supreme Court rejects Trump bid to void California sanctuary law
"Now, more than ever, we must be resolved to keep fighting on behalf of our immigrant communities and those who have relied on DACA for their livelihood and peace of mind. The contributions DACA recipients are making to our nation and county are immeasurable. The economic and human stakes are too high -- they deserve and will have our continued support.''
Los Angeles Unified School District Superintendent Austin Beutner said he was relieved and thankful'' at the ruling.
"It is the right outcome for so many families and their teachers who have been living under a cloud of uncertainty,'' Beutner said. "However, we must continue to press for a permanent legislative solution and comprehensive immigration reform from Congress.''
For now, the young immigrants retain their protection from deportation and their authorization to work in the United States.
Roberts wrote for the court that the administration did not pursue the end of the program properly.
"We do not decide whether DACA or its rescission are sound policies," Roberts wrote. "We address only whether the agency complied with the procedural requirement that it provide a reasoned explanation for its action. Here the agency failed to consider the conspicuous issues of whether to retain forbearance and what if anything to do about the hardship to DACA recipients."
As Roberts noted, the Department of Homeland Security can try again. But any new order to end the program, and the legal challenge it would provoke, would take months, if not longer, immigration experts said.
Thursday's ruling was the second time in two years that Roberts and the liberal justices faulted the administration for the way it went about a policy change. Last year, the court forced the administration to back off a citizenship question on the 2020 census.
The Associated Press and City News Service contributed to this report.