A federal judge in San Francisco on Tuesday night ordered the Trump administration to partially revive the Deferred Action for Childhood Arrivals program, finding that challengers to the administration's decision to end the program were likely to succeed in their claims that President Trump’s move was "arbitrary and capricious."

Under the order from US District Judge William Alsup, the Trump administration must resume accepting renewal applications from individuals who were already enrolled in the program. Alsup did not order the administration to accept new applications, however, writing that the plaintiffs had shown only that existing recipients were likely to suffer "irreparable harm" absent immediate intervention from the court. The president attacked the decision via Twitter on Wednesday, saying it showed the justice system was "broken and unfair."

Trump on Tuesday continued negotiations with congressional leaders about a possible deal to revive the program's protections ahead of a March deadline, potentially in exchange for tighter border security. The Justice Department is likely to appeal Alsup’s decision. Alsup issued his ruling in five cases filed in California challenging the rescission. The plaintiffs included the University of California, several states, California municipalities, and individual DACA recipients.

The judge picked apart Attorney General Jeff Sessions' rationale for declaring that the DACA program was unlawful, finding that the rescission "was based on the flawed legal premise that the agency lacked authority to implement DACA." Alsup cited a 2014 memo issued by the Justice Department’s Office of Legal Counsel that explained that the Department of Homeland Security could exercise its discretion by granting deferred action to some immigrants who were unlawfully in the United States but considered a low priority for deportation.

He rejected the government's alternative argument that the Department of Homeland Security acted within its authority by managing its exposure to pending litigation filed by Republican state attorneys general challenging DACA. But Alsup wrote that the record showed that the rescission decision was rooted in Sessions’ finding that the program was unlawful, and the administration couldn't push an alternative explanation after the fact.

The judge concluded that the challengers were likely to suffer irreparable harm without immediate action from the court to partially continue the DACA program as the litigation went forward.

The judge noted that there wouldn't be a complete administrative record until after the March 5 deadline, which delayed the court's ability to issue a final judgment that could be appealed. The challengers were entitled to get a chance to look at the full record before the court took final action, the judge concluded.

The judge made clear that his order would not stop the government from deporting anyone, including DACA recipients, "who it determines poses a risk to national security or public safety, or otherwise deserves, in its judgment, to be removed."

Alsup also denied the government's motion to dismiss the lawsuits, rejecting arguments that the court lacked authority to review the Department of Homeland Security's decision.