CNN  — 

A federal judge on Friday upheld his order that the Deferred Action for Childhood Arrivals program should be fully restored, setting a 20-day deadline for the administration to do so.

DC District Judge John Bates said the Trump administration still has failed to justify its proposal to end DACA, the Obama-era program that has protected from deportation nearly 800,000 young undocumented immigrants brought to the US as children.

But Bates agreed to delay his ruling for 20 days to give the administration time to respond and appeal, if it chooses.

The ruling sets up potentially conflicting DACA orders from federal judges by the end of the month.

The decision comes less than a week before a hearing in a related case in Texas. In that case, Texas and other states are suing to have DACA ended entirely, and the judge is expected to side with them based on his prior rulings.

Justice Department spokesman Devin O’Malley indicated the department would take further action, suggesting that an appeal might be filed. He reiterated the Justice Department still believes the same reasoning the judge rejected, that DACA is “an unlawful circumvention of Congress,” and DHS has the authority to end it.

“The Justice Department will continue to vigorously defend this position, and looks forward to vindicating its position in further litigation,” O’Malley said in a statement.

Previous court rulings in California and New York have already prevented the administration from ending DACA, but they only ordered the government to continue renewing existing applications. Bates’ ruling would go further and order the program reopened in its entirety. The earlier decisions are pending before appeals courts.

Bates on Friday upheld a ruling he had issued in April that ordered the administration to begin accepting DACA applications again. He had postponed that order for 90 days to give the government time to offer a better legal justification for its decision last September to end the program.

The Department of Homeland Security followed up by largely reiterating its previous argument: that DACA was likely to be found unconstitutional in the Texas case if it were challenged there and thus it had to end. Homeland Security Secretary Kirstjen Nielsen also said in the DHS response that the agency had the discretion to end the program, as much as its predecessors had the discretion to create it.

Bates, a George W. Bush appointee, found that explanation unsatisfactory, and said the DHS could not invent a new justification for his court, either. He said most of the arguments “simply repackage legal arguments previously made” and fail to pass muster.

“Although the Nielsen Memo purports to offer further explanation for DHS’s decision to rescind DACA, it fails to elaborate meaningfully on the agency’s primary rationale for its decision,” Bates wrote. “The memo does offer what appears to be one bona fide (albeit logically dubious) policy reason for DACA’s rescission, but this reason was articulated nowhere in DHS’s prior explanation for its decision, and therefore cannot support that decision now.”

Bates said the administration had created a “dilemma” for itself by both trying to rely on its previous decision and offering a new one.

“The government’s attempt to thread this needle fails,” he wrote.

CNN’s Ariane de Vogue contributed to this report.