The Supreme Court has ruled against the Trump Administration’s attempt to overturn the Deferred Action for Childhood Arrivals Act, an Obama-era executive order that gave the children of undocumented immigrants -- known as Dreamers -- the right to stay in the country.

The 5-4 ruling, handed down Thursday morning, is seen as a blow against President Donald Trump’s hard-line tactics on immigration -- including his attempt in 2017 to end DACA that Justice Sonia Sotomayor called “contaminated by impermissible discriminatory animus.”

Chief Justice John Roberts wrote the majority opinion, joined by Justices Ruth Bader Ginsburg, Stephen Breyer and Elena Kagan. Sotomayor joined all but one section and wrote her own concurring opinion exploring the influence of Trump’s racist remarks against Mexican immigrants on the Department of Homeland Security.

Justices Clarence Thomas, Samuel Alito, Neil Gorsuch and Brett Kavanaugh dissented.

In his opinion, Roberts rebuked the Department of Homeland Security’s handling of rescinding DACA: “The dispute before the Court is not whether DHS may rescind DACA. All parties agree that it may. The dispute is instead primarily about the procedure the agency followed in doing so,” he wrote. “We concluded that the total rescission was arbitrary and capricious.”

Thomas wrote in his dissenting opinion that “today’s decision must be recognized for what it is: an effort to avoid a politically controversial but legally correct decision.”

“The court could have made clear that the solution respondents seek must come from the legislative branch,” Thomas said.

The DACA program was authorized in 2012 by President Barack Obama through executive action, and about 825,000 DACA recipients in the country have benefited from the program since its beginning, including 30,000 recipients in New York City.

Thursday’s ruling affects at least 17,200 New York City residents who are currently active DACA recipients, according to the Center for American Progress. Many DACA recipients, including co-plaintiff Antonio Alarcón of Jackson Heights, are calling on Congress to create a path to full legalization for themselves and other young people who are undocumented, as well as their parents.

Roberts’s opinion does not attempt to weigh the morality of DACA, and leaves the door open for DHS to revisit other legal challenges.

“We do not decide whether DACA or its rescission are sound policies,” he 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. That dual failure raises doubts about whether the agency appreciated the scope of its discretion or exercised that discretion in a reasonable manner. The appropriate recourse is therefore to remand to DHS so that it may consider the problem anew.”

In her concurring opinion, Sotomayor writes she believes Roberts's opinion doesn't fully examine how Trump’s legacy of “discriminatory animus” in his comments about immigrants, particularly Latino immigrants, plays a role in his administration's actions.

During his campaign, Trump said “‘Mexican immigrants are “people that have lots of problems,” “the bad ones,” and “criminals, drug dealers, [and] rapists,’” Sotomayor wrote. As president, in 2017 Trump made statements “comparing ‘undocumented immigrants to “animals” responsible for “the drugs, the gangs, the cartels, the crisis of smuggling and trafficking, [and] MS13.’”

She said that his comments and attitude towards immigration “were an animating force” for rescinding DACA. “Nor did any of the statements arise in unrelated contexts. They bear on unlawful migration from Mexico—a keystone of President Trump’s campaign and a policy priority of his administration—and, according to respondents, were an animating force behind the rescission of DACA.”

“Taken together, “the words of the President” help to “create the strong perception” that the rescission decision was “contaminated by impermissible discriminatory animus,’” Sotomayor wrote.

On Twitter, Trump appeared to take the ruling personally, and reacted with violent language calling the Supreme Court's recent rulings "shotgun blasts into the face of people that are proud to call themselves Republicans or Conservatives."

Update: Martin Batalla Vidal, 29, is among the six New York plaintiffs who filed suit along with the immigrant advocacy group Make the Road New York. Vidal was the very first DACA recipient to sue the federal government back in 2016, after the state of Texas successfully won a lawsuit to reduce the duration of DACA work permits from three to two years.

After hearing about the Supreme Court decision, “I was in shock. And I just started crying and crying,” he said in a phone interview Thursday.

Vidal went to visit his mother, who lives near him in Queens, and told her, "I am who I am because you brought me to this country."

He now works at a rehabilitation clinic for people with traumatic brain injuries, where he helped some patients who contracted COVID-19. Vidal said he believes more people appreciate the contribution of DACA recipients since they were among the front-line workers during the pandemic, and were also directly affected by the disease -- his own mother was hospitalized for three weeks.

But he doesn't think a permanent solution to DACA will come until a new president is elected, given the deadlock in Congress. So he's looking forward to the next fight.

"I’ll be volunteering," Vidal said, "getting people to register, doing community outreach, knocking on doors making sure they register to vote."

Another plaintiff and member of Make The Road NY, Carolina Fung Feng, said she felt victorious after three years in which she feared losing her work permit and being deported. "I will hold my loved ones a little bit tighter and tomorrow I will continue to fight for a permanent protection for undocumented youth and all 11 million undocumented people living in this country,” she said at a press conference Thursday.

State Assemblywoman Catalina Cruz, herself a Dreamer, said through tears, “It’s really hard as much as we want allies to understand the pain we’re living through today, it’s really hard to explain having to live in that limbo for so long. Our kids deserve so much better. And I’m so glad the Supreme Court made the right, sound legal decision and the humane decision. Because for a very long time, let’s be real, we didn’t think this was going to go this way. And now what we’ve got to do is make sure this becomes permanent.”

“During his time in the White House, President Trump has been unrelenting in his attacks on immigrant communities in the United States—from jailing and deporting thousands, to severely restricting lawful immigration, to militarizing the border. At the insistence of courageous immigrant communities and their allies who sued the Trump Administration, courts have stepped in to stop those illegal and horrifying attacks from time to time. This is an incredible victory fought for and won by the very people Trump continues to want to exclude from our country. Today’s Supreme Court decision is a great day for our country,” said Marielena Hincapié, Executive Director of the National Immigration Law Center in a statement.

On Thursday afternoon, U.S. Citizenship and Immigration Services Deputy Director for Policy Joseph Edlow issued a statement challenging the ruling:

“Today’s court opinion has no basis in law and merely delays the President’s lawful ability to end the illegal Deferred Action for Childhood Arrivals amnesty program. DACA was created through an Executive Branch memorandum after President Obama said repeatedly that it was illegal for him to do so unilaterally and despite the fact that Congress affirmatively rejected the proposal on multiple occasions. The constitutionality of this de facto amnesty program created by the Obama administration has been widely questioned since its inception. The fact remains that under DACA, hundreds of thousands of illegal aliens continue to remain in our country in violation of the laws passed by Congress and to take jobs Americans need now more than ever. Ultimately, DACA is not a long-term solution for anyone, and if Congress wants to provide a permanent solution for these illegal aliens it needs to step in to reform our immigration laws and prove that the cornerstone of our democracy is that presidents cannot legislate with a ‘pen and a phone.’”

The cases are now remanded back to district courts in New York and California where the DHS can reconsider.