A federal judge ruled Monday that President Trump’s phaseout of the Obama-era DACA program is legal, adding heft to the administration’s defense but doing little to solve the ongoing court quagmire.

The ruling does not overturn two other federal courts, who had previously blocked the phaseout, which was supposed to take effect Monday. But it does offer a needed boost as the Justice Department appeals those other two rulings.

Judge Roger W. Titus, a Bush appointee to the bench in Maryland, said the judges in California and New York who blocked the phaseout attempted to substitute their own judgments for that of the Homeland Security Department, crossing constitutional lines in order to strike at Mr. Trump’s policies.

SEE ALSO: ‘Dreamers’ turn ire on Democrats as DACA deadline passes

Judge Titus went even further, praising the Trump administration for the way it handled the situation with a six-month phaseout.

“This decision took control of a pell-mell situation and provided Congress — the branch of government charged with determining immigration policy — an opportunity to remedy it. Given the reasonable belief that DACA was unlawful, the decision to wind down DACA in an orderly manner was rational,” the judge wrote.

DACA is the 2012 program Mr. Obama created, using executive authority, to protect hundreds of thousands of “Dreamers” from deportation and to give them a foothold in society. Some 683,000 people were being protected as of Jan. 31.

But the program was always legally questionable, and Mr. Trump last September, facing threats of lawsuits from Texas and other states, announced his phaseout, with a final deadline of March 5.

Immigrant-rights groups across the country objected, and many of them sued, with at least five cases in California, two in New York, one in Washington, D.C., and one in Maryland.

The judge in the California case ruled in January, imposing a nationwide halt on the phaseout in an expansive opinion blasting the administration for its handling. A judge in the New York cases last month issued a more carefully crafted ruling but reached the same conclusion that the DACA program itself is legal as Mr. Obama wrote it, and that the Trump administration didn’t give a good enough justification for its phaseout, making it arbitrary.

Judge Titus, though, said the administration was facing a credible legal threat from Texas, and the attorney general had doubts about mounting a defense, so the Homeland Security Department’s decision was not arbitrary.

He also took on those who said Mr. Trump’s past comments about illegal immigrants soured the case.

“As disheartening or inappropriate as the president’s occasionally disparaging remarks may be, they are not relevant to the larger issues governing the DACA rescission. The DACA Rescission Memo is clear as to its purpose and reasoning, and its decision is rationally supported by the administrative record,” the judge wrote.

Justice Department spokesman Devin O’Malley said the ruling was “good news,” but said it underscored the judicial overreach of the New York and California courts, who issued national injunctions, making Judge Titus’s ruling nearly irrelevant in effect.

Judge Titus did grant DACA beneficiaries one victory, ruling that none of their information they turned over to apply for the program can be used by immigration agents to deport them.

If the administration wants to use information, it must petition the court in each case, the judge said.

Judge Titus said he didn’t like the result of his own ruling, but he said judges need to butt out of politics and stick to the law.

“This court does not like the outcome of this case, but is constrained by its constitutionally limited role to the result that it has reached,” he wrote. “Hopefully, the Congress and the president will finally get their job done.”