Trump last year announced his plan to end DACA, the policy that allowed undocumented immigrants brought to the US as children to stay in the country, effective March 5. That deadline has become central in the congressional debate over immigration, but Democrats and Republicans are nowhere near a breakthrough.

"Defendants indisputably can end the DACA program," Garaufis wrote, referring to the Trump administration. "The question before the court is thus not whether defendants could end the DACA program, but whether they offered legally adequate reasons for doing so. Based on its review of the record before it, the court concludes that defendants have not done so."

The judge said that the decision to end the program was based in part on the "plainly incorrect factual premise" that the program was illegal.

"Today's ruling shows that courts across the country agree that Trump's termination of DACA was not just immoral, but unlawful as well," said Karen Tumlin of the National Immigration Law Center.

This week the Supreme Court is set to meet behind closed doors to discuss whether to take up the Trump administration's appeal of the related case.

The Justice Department said it maintains that the administration acted "within its lawful authority" in deciding to end DACA and will "vigorously defend this position."

"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," the Justice Department said in a statement. "Promoting and enforcing the rule of law is vital to protecting a nation, its borders, and its citizens."

Impact on immigration negotiations

Sen. Thom Tillis, R-North Carolina, urged lawmakers to "focus" on March 5, despite the two district court rulings blocking the DACA drawdown, but acknowledged there will be more time.

"We should still focus on the March 5 date," Tillis said on Fox News Tuesday afternoon. "The reality is, unless there's any action by the Supreme Court, looks like we have some number of weeks following March 5 to solve the problem."