LGBT groups on Thursday cheered a Supreme Court ruling that affirmed protections for recipients of the Deferred Action for Childhood Arrivals (DACA) program.

President Donald Trump attempted to dismantle DACA, which allows the children of undocumented immigrants, known as “dreamers,” to remain in the United States. Former President Barack Obama signed the executive order creating the program in 2012.

Writing for the 5-4 majority, Chief Justice John Roberts said that Obama had the authority to create the program and that Trump has the authority to end it. But Roberts added that Trump's “total rescission” of DACA was “arbitrary and capricious.”

The Human Rights Campaign (HRC), the nation's largest LGBT rights advocate, applauded the decision, saying it affects thousands of LGBT dreamers.

“This is a critical step in the right direction for young people across the country,” HRC President Alphonso David said in a statement. “The DACA program provides an opportunity for young people, including LGBTQ Dreamers, to live productive, safe and happy lives in the United States. Today’s ruling by the Supreme Court keeps the DACA program in place, but there is still work left to be done. Now, we must elect pro-equality leaders to Congress to pass a clean DREAM Act – that is how we permanently protect the nearly two million Dreamers, for whom today’s ruling is only a temporary solution.”

“The U.S. Supreme Court has not only given 700,000 DACA recipients a chance to remain in the only home they have ever known,” GLAAD said in a tweet, “but has rebuked the Trump Administration's ongoing efforts to demonize and hurt hard-working immigrant families.”

The National Center for Lesbian Rights (NCLR) said in a tweet that it was celebrating the ruling.

“Today #SCOTUS ruled that #DACA recipients – over 39,000 of whom are #LGBTQ – cannot be deported from the only country many of them have ever known,” the group said. “#NCLR's #Immigration Project joins in celebrating this decision.”

Trump criticized the decision in a tweet, calling it and other rulings against his administration “shotgun blasts into the face of people that are proud to call themselves Republicans or Conservatives.”