For the second time in two months, a federal judge has stepped into an intense political fight over immigration policy, issuing an injunction that orders the Trump administration to keep in place the embattled program known as DACA, which protects young undocumented immigrants from deportation.

The nationwide injunction, issued on Tuesday by Judge Nicholas G. Garaufis of Federal District Court in Brooklyn, came one month after a court in California also ruled that the administration needed to spare DACA, or Deferred Action for Childhood Arrivals. Judge Garaufis’s ruling in many ways echoed the one issued by Judge William Alsup of Federal District Court in San Francisco. But it also offered additional reasons for why DACA should remain in place as the case continues through the courts, and it detailed the harms that its repeal would cause to young immigrants and others.

On Sept. 5, the attorney general, Jeff Sessions, announced that the Trump administration planned to end DACA gradually, saying that the program had been unconstitutionally established by President Barack Obama in 2012. Under the rollback, the Department of Homeland Security is still considering pending DACA applications and renewal requests from recipients who filed by Oct. 5. But the department plans to reject all applications after that.

After Mr. Sessions’s announcement, a coalition of immigration lawyers and a group of 16 Democratic state attorneys general, led by Eric Schneiderman of New York, filed separate but linked lawsuits in Brooklyn, claiming that the repeal of DACA was an “arbitrary and capricious” decision largely motivated by a “racial animus” against Latinos. In his ruling, Judge Garaufis agreed with the lawyers that the rollback was arbitrary and capricious; but while he has vociferously criticized Mr. Trump from the bench for his anti-immigrant tweets and public statements, the judge made no mention of racial animus in his findings.