A second federal appeals court on Friday ruled against the Trump administration in its attempt to roll back the Obama-era Deferred Action for Childhood Arrivals program and said its decision to do so was unlawful.

A divided three-judge panel on the 4th U.S. Circuit Court of Appeals said in its ruling that the Department of Homeland Security’s decision to rescind the DACA program violated federal law because “it was not adequately explained and thus was arbitrary and capricious.”

The Richmond-based federal appeals court is the second appeals court to rule against President Trump in his attempt to wind down the DACA program, which was implemented by the Obama administration in 2012 and protected immigrants brought to the U.S. illegally as children from the threat of deportation.

In November, the 9th U.S. Circuit Court of Appeals upheld a lower court order blocking the government from rescinding the DACA program. The San Francisco-based court said then that plaintiffs in that challenge to the administration’s efforts to end DACA were likely to succeed in their claim that the rescission “is arbitrary, capricious, or otherwise not in accordance with law.”

The Justice Department has asked the Supreme Court to take up the dispute over its attempted rollback, though the court has not acted on numerous petitions currently before it.

The Trump administration announced in 2017 that it would be ending the DACA program, and the Department of Homeland Security predicated its decision on the grounds DACA was unlawful to begin with.

But the president’s move was met with a host of lawsuits filed by immigrant-rights groups and individuals who argued DACA’s wind down violated federal law and the Constitution.

Federal district court judges in Washington, D.C., New York, and San Francisco delivered losses to the Trump administration and blocked it from moving forward with DACA’s rollback. But one judge in Greenbelt, Md., sided with the Trump administration and said the president acted within his authority to wind down the Obama-era program.

The 4th Circuit, however, reversed the ruling from the federal judge in Maryland that upheld DACA's rescission.

In its ruling against the Trump administration, the 4th Circuit said the Department of Homeland Security failed to account for those affected by the decision.

“Hundreds of thousands of people had structured their lives on the availability of deferred action during the over five years between implementation of DACA and the decision to rescind it,” the court said. “Although the government insists that Acting Secretary [Elaine] Duke considered these interests in connection with her decision to rescind DACA, her memo makes no mention of them.”

Judge Julius Richardson, a Trump appointee, dissented and said the executive branch's rollback of DACA is judicially unreviewable.

"We in the judicial branch have a narrowly circumscribed role. It is not our place to second-guess the wisdom of the discretionary decisions made by the other branches," Richardson wrote. "The rescission of DACA was a controversial and contentious decision, but one that was committed to the executive branch."

[Previous coverage: Trump: I have 'scary' amount of power if Supreme Court says DACA can't be dismantled]