A federal court judge in Brooklyn put a stop, at least for now, to President Donald Trump’s plan to wind down a program that shielded nearly 800,000 young immigrants known as Dreamers from deportation.

The preliminary injunction Tuesday by U.S. District Judge Nicholas Garaufis means those immigrants brought to the country illegally as children — and who have been protected under the Deferred Action for Childhood Arrivals, or DACA — can renew their enrollment in the program.

Garaufis’ decision coincides with a separate ruling issued last month by a federal judge in California that is moving closer to consideration by the U.S. Supreme Court. Immigrant advocates said both cases bolster their arguments to keep DACA alive.

In his decision, Garaufis said that while the president and his administration “have broad discretion to set immigration-enforcement priorities,” the government was treading “on erroneous legal ground” in ending the program.

“Defendants do not appear to have rescinded the DACA program as an exercise of their discretion, or because of a reasoned policy judgment,” Garaufis wrote, “but instead, at least in significant part, because they erroneously concluded that the program was unconstitutional and unlawful.”

The Trump administration held fast Tuesday to its argument that DACA was an unacceptable exercise of executive powers under former President Barack Obama.

“Today’s order doesn’t change the Department of Justice’s position on the facts: DACA was implemented unilaterally after Congress declined to extend these benefits to this same group of illegal aliens. As such, it was an unlawful circumvention of Congress,” said Devin O’Malley, a spokesman for the U.S. Department of Justice, in a statement. “The Justice Department will continue to vigorously defend this position.”

Immigrant advocates said the ruling affirmed the argument they have been making all along: that the former president correctly exercised prosecutorial discretion in putting in place the program to protect those young immigrants.

Sign up to get the latest updates

The Trump administration “was wrong on the law; it was wrong on the facts and . . . it was internally inconsistent” in its arguments, said Susanna Evarts, a law student serving as counsel in the case on behalf of the Worker and Immigrant Rights Advocacy Clinic at Yale Law School. “The court’s ruling today is a strong statement to the government that it cannot pull the rug from underneath 700,000 individuals without properly justifying such a monumental action.”

However, even advocates agreed that Tuesday’s ruling is “not the endgame” on DACA. The U.S. Supreme Court may consider oral arguments on a related case as soon as this week and Congress is pondering a legislative solution.

The Brooklyn case was originally filed on behalf of Martín Jonathan Batalla Vidal against the secretary of the Department of Homeland Security.

Batalla Vidal, a native of Mexico who lives in Ridgewood, Queens, and works at a nursing home, told Newsday during a September 2017 interview that he’s been in the country since he was 7 or 8 and that Dreamers just want a fair chance.

“We are not criminals,” he said. “All we want is an opportunity . . . to work and live the American Dream.”