CHICAGO (CBS) — A visibly emotional Mayor Lori Lightfoot on Thursday praised a U.S. Supreme Court ruling blocking the Trump administration’s attempt to dismantle an Obama-era program that protects young undocumented immigrants from deportation.

“It’s a great day. It’s a great day,” Lightfoot said Thursday morning, choking up as she spoke about the high court’s 5-4 ruling.

The Supreme Court decision provided a lifeline to nearly 700,000 immigrants whose future in the United States hung in the balance while a yearslong legal battle over the Deferred Action for Childhood Arrivals (DACA) program moved through the courts.

“This is an important, important ruling. I think it will go down as one of the most historic rulings in the history of the Supreme Court, and I am overjoyed that this decision has been rendered,” Lightfoot said.

Chief Justice John Roberts, who joined the four liberals justices on the bench, delivered the opinion for the court, writing that the Trump administration’s decision to unwind the program was “arbitrary and capricious” under the Administrative Procedure Act.

Roberts wrote the court does “not decide whether DACA or its rescission are sound policies,” but said the Department of Homeland Security should revisit the issue.

“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,” he wrote for the majority. “That dual failure raises doubts about whether the agency appreciated the scope of its discretion or exercised that discretion in a reasonable manner.”

Lightfoot said the ruling would have a “huge” impact for Chicago, which is home to a large population of undocumented immigrants. The DACA program was created by the Obama administration in 2012 and extends legal protections for young immigrants brought to the U.S. illegally as children.

“There are so many young people who contribute in incredible ways to the vibrancy of our country. They deserve and have the right to be here, and I am grateful,” the mayor said. “There are so many young people who are DACA eligible, who have been hanging on by a thread, and really not knowing what their future was gonna hold; worrying about going away to another country that they have no memory or knowledge of.”

“So I think that this ruling really speaks to the importance of supporting, unequivocally, immigrant and refugee rights. You know that we are a welcoming city, we will always be a welcoming city, and being a welcoming city doesn’t mean taking half measures. We must, we must protect all of our immigrant and refugee communities, and particularly our young people,” she added. “I am overcome with joy and relief for them. We had no idea which way the pendulum was gonna swing, and we were unfortunately preparing for the worst. I am glad on this bright, June day that we have something more to smile about.”

The mayor said the ruling would provide a measure of comfort to young immigrants who were brought to the country illegally, so they don’t have to worry about living in the shadows, and being denied opportunities to pursue their dreams.

President Trump chided the Supreme Court’s decision in the DACA case, as well as a ruling earlier this week that expanded federal workplace protections to LGBTQ people, tweeting “Do you get the impression that the Supreme Court doesn’t like me?”

“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 & everything else. Vote Trump 2020!” the president said in another tweet.

The decision from the high court comes against the backdrop of the coronavirus pandemic, during which thousands of so-called “Dreamers” covered by the program who work in the medical field found themselves on the front lines of the public health crisis that has taken the lives of more than 117,000 people in the U.S.

In March, lawyers representing Dreamers asked the justices to take the pandemic into account when deciding whether to bless the Trump administration’s decision to unwind DACA. They estimated roughly 27,000 DACA recipients are healthcare workers, while another 200 are medical students.

“DACA recipients are essential to protecting communities across the country endangered by COVID-19,” the lawyers told the Supreme Court. “Termination of DACA during this national emergency would be catastrophic.”

It has been nearly three years since the Trump administration announced it would be rescinding DACA. At the time, in September 2017, the Trump administration provided Congress with a five-month window to codify DACA’s legal protections. But lawmakers failed to reach consensus on a broader immigration reform package that would address the fate of Dreamers.

In justifying its decision, the Trump administration cited a 2015 ruling from the 5th U.S. Circuit Court of Appeals in a challenge to a similar program implemented by President Barack Obama, known as Deferred Action for Parents of Americans. The lower court ruled that program was unlawful, and an equally divided Supreme Court affirmed the 5th Circuit’s decision with a 4-4 ruling in the summer of 2016.

But states, civil rights groups and Dreamers argued the Trump administration failed to provide an adequate explanation for its decision to end the program, violating federal law, and rested its repeal of DACA on the faulty premise that the program is unlawful.

Lower courts in the District of Columbia, California and New York have sided with the coalition challenging the administration’s roll back in various legal battles and have ordered the Trump administration to keep DACA intact.

The Supreme Court agreed in June 2019 to take up the legal fight over DACA and held arguments in November, during which the conservative justices seemed ready to side with the Trump administration.

“Today’s decision must be recognized for what it is: an effort to avoid a politically controversial but legally correct decision,” Thomas wrote. “The court could have made clear that the solution respondents seek must come from the legislative branch. Instead, the majority has decided to prolong DHS’ initial overreach by providing a stopgap measure of its own. In doing so, it has given the green light for future political battles to be fought in this court rather than where they rightfully belong — the political branches.”

Thomas wrote the decision in rebuffing the Trump administration’s efforts to unwind DACA “creates perverse incentives, particularly for outgoing administrations.”

Mr. Trump made immigration a cornerstone of his 2016 presidential campaign and vowed to “immediately terminate” DACA if he were elected president. In addition to following through on his pledge to unwind the Obama-era program, Mr. Trump has also overseen a crackdown on illegal and legal immigration and imposed restrictions on asylum-seekers arriving at the southern border.

While he has defended his efforts to end the program, the president has also acknowledged the sweeping impact its rescission would have on hundreds of thousands of Dreamers. In October, Mr. Trump said on Twitter that if the Supreme Court were to allow his administration to end DACA, Republicans and Democrats would reach a deal to allow Dreamers to remain in the U.S. “in very short order.”

But legislative action has slowed to a crawl since the coronavirus began to rapidly spread across the U.S. in March, as Congress shifted its focus to responding to the crisis.