NEW YORK, NY - AUGUST 15:  Dozens of immigration advocates and supporters attend a rally outside of  Trump Tower along Fifth Avenue on August 15, 2017 in New York City. The activists were rallying on the five-year anniversary of President Obama's executive order, DACA - Deferred Action for Childhood Arrivals, protecting undocumented immigrants brought to the U.S. as children. Security throughout the area is high with President Donald Trump in residency at the tower, his first visit back to his apartment since his inauguration. Numerous protests and extensive road closures are planned for the area.  (Photo by Spencer Platt/Getty Images)
PHOTO: Spencer Platt/Getty Images
NEW YORK, NY - AUGUST 15: Dozens of immigration advocates and supporters attend a rally outside of Trump Tower along Fifth Avenue on August 15, 2017 in New York City. The activists were rallying on the five-year anniversary of President Obama's executive order, DACA - Deferred Action for Childhood Arrivals, protecting undocumented immigrants brought to the U.S. as children. Security throughout the area is high with President Donald Trump in residency at the tower, his first visit back to his apartment since his inauguration. Numerous protests and extensive road closures are planned for the area. (Photo by Spencer Platt/Getty Images)
Now playing
02:30
Trump's twists and turns on DACA
Michael Caputo
PHOTO: CNN
Michael Caputo
Now playing
01:25
Caputo: Trump tired of Dems gaming on DACA
A group of Central Americans crossed into Mexico in March as part of a migrant "caravan" heading to the United States border.
PHOTO: CNN
A group of Central Americans crossed into Mexico in March as part of a migrant "caravan" heading to the United States border.
Now playing
02:07
Donald Trump: No more DACA deal
PHOTO: CNN
Now playing
01:38
Kaine: Trump could fix DACA if he wanted to
WASHINGTON, DC - JANUARY 09:  U.S. President Donald Trump (L) presides over a meeting about immigration with Republican and Democrat members of Congress in the Cabinet Room at the White House January 9, 2018 in Washington, DC. In addition to seeking bipartisan solutions to immigration reform, Trump advocated for the reintroduction of earmarks as a way to break the legislative stalemate in Congress.  (Photo by Chip Somodevilla/Getty Images)
PHOTO: Chip Somodevilla/Getty Images North America/Getty Images
WASHINGTON, DC - JANUARY 09: U.S. President Donald Trump (L) presides over a meeting about immigration with Republican and Democrat members of Congress in the Cabinet Room at the White House January 9, 2018 in Washington, DC. In addition to seeking bipartisan solutions to immigration reform, Trump advocated for the reintroduction of earmarks as a way to break the legislative stalemate in Congress. (Photo by Chip Somodevilla/Getty Images)
Now playing
01:12
Trump changes tone on immigration
PHOTO: CNN
Now playing
00:59
Pelosi: I'm going to go on as long as allowed
What is DACA?_00002803.jpg
What is DACA?_00002803.jpg
Now playing
01:57
What is DACA?
PHOTO: CNN
Now playing
00:54
White House wants permanent DACA solution
PHOTO: CNN
Now playing
01:33
Senators say McConnell willing to deal on DACA
WASHINGTON, DC - SEPTEMBER 6: Senate Minority Leader Chuck Schumer (D-NY) speaks at a news conference as other congressional leaders look on about President Donald Trump's decision to end the Deferred Action for Childhood Arrivals (DACA) program at the U.S. Capitol September 6, 2017 in Washington, DC. Democrats called for action on young undocumented immigrants that came to the U.S. as children who now could face deportation if Congress does not act.  (Photo by Aaron P. Bernstein/Getty Images)
PHOTO: Aaron P. Bernstein/Getty Images
WASHINGTON, DC - SEPTEMBER 6: Senate Minority Leader Chuck Schumer (D-NY) speaks at a news conference as other congressional leaders look on about President Donald Trump's decision to end the Deferred Action for Childhood Arrivals (DACA) program at the U.S. Capitol September 6, 2017 in Washington, DC. Democrats called for action on young undocumented immigrants that came to the U.S. as children who now could face deportation if Congress does not act. (Photo by Aaron P. Bernstein/Getty Images)
Now playing
01:11
Trump tweets DACA 'probably dead'
US President Donald Trump, and wife Melania step off Air Force One upon arrival at Palm Beach International Airport in West Palm Beach, Florida on January 12, 2018.
Trump is heading to Palm Beach, Florida where he is scheduled to spend the weekend at the Mar-a-Lago estate. / AFP PHOTO / Nicholas Kamm        (Photo credit should read NICHOLAS KAMM/AFP/Getty Images)
PHOTO: NICHOLAS KAMM/AFP/AFP/Getty Images
US President Donald Trump, and wife Melania step off Air Force One upon arrival at Palm Beach International Airport in West Palm Beach, Florida on January 12, 2018. Trump is heading to Palm Beach, Florida where he is scheduled to spend the weekend at the Mar-a-Lago estate. / AFP PHOTO / Nicholas Kamm (Photo credit should read NICHOLAS KAMM/AFP/Getty Images)
Now playing
02:01
Trump: Democrats don't want DACA deal
Trump
PHOTO: CNN
Trump
Now playing
01:12
Trump: Immigration bill must be 'bill of love'
Sen. Jeff FLake lead 12-20-17
PHOTO: CNN
Sen. Jeff FLake lead 12-20-17
Now playing
02:07
How Flake used his leverage to revisit DACA
pelosi dreamers event 1
PHOTO: KGO
pelosi dreamers event 1
Now playing
01:15
Protesters drown out Nancy Pelosi
What is DACA?_00002803.jpg
What is DACA?_00002803.jpg
Now playing
02:01
One of these bills could replace DACA
(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.