Washington (CNN) The Justice Department told the Supreme Court late Monday night that the Trump administration acted lawfully when it decided in 2017 to wind down the Deferred Action for Childhood Arrivals program , which protects undocumented immigrants who came to the United States as children from deportation.

"At best, DACA is legally questionable," Solicitor General Noel Francisco argued in legal briefs. "At worst, it is illegal."

Francisco stressed that the executive branch was within its authority to phase out the Obama-era program and that the lower courts "erred" in "second-guessing" the Department of Homeland Security's "entirely rational judgment to stop facilitating ongoing violations of federal law on a massive scale."

As things stand, two nationwide preliminary injunctions issued by lower courts have forced DHS to continue to allow renewals in the program for nearly two years.

The legal brief comes as the Supreme Court will hear arguments in the case on November 12. The program has become a focal point in the debate over Trump's proposed US-Mexico border wall and efforts to crack down on immigration. A decision siding with the administration could strip protections for nearly 700,000 so-called Dreamers in a case that will come down in the heat of the next election.

Back in 2017, the Trump administration announced it was going to phase out DACA, which it said had been created "without proper statutory authority."

The move was immediately challenged in court by the University of California, a handful of states and DACA recipients who argued that the phase-out violated the Administrative Procedure Act, a federal law that governs how agencies can establish regulations.

Courts agreed and issued nationwide injunctions that allowed renewals in the program to continue.

"We conclude," wrote a panel of the 9th Circuit Court of Appeals, that the rescission of DACA "is arbitrary, capricious or otherwise not in accordance with law."

The Trump administration appealed the decision to the Supreme Court, and last June, the justices agreed to hear the appeal for the upcoming term.

At issue before the Supreme Court is not the legality of the program but how the administration decided to wind it down.

In the new briefs, Francisco argues that the decision to terminate the program was reasonable because the Department of Homeland Security had "serious doubts" about its legality. He said the decision was "more than justified by DHS's serious doubts about the lawfulness of the policy and the litigation risks in maintaining it."

Supporters of the program urged the court to reject the administration's arguments.