In a setback for the Trump administration, an appeals court ruled the administration could not circumvent Congress by transferring billions in Department of Defense funds for border wall construction, records show.

On Friday, judges for the 9th Circuit Court of Appeals ruled that it was unlawful for the Trump administration to transfer Department of Defense money, specifically military pay and pension funds, for border wall construction.

The three-judge panel held that the Executive Branch lacked “independent constitutional authority to authorize the transfer of funds” — and reaffirmed a lower court’s ruling that halted construction related to those funds with a permanent injunction.

Chief Judge Sidney R. Thomas gave the court’s opinion; in addition, U.S. Circuit Judge Kim McLane Wardlaw and Circuit Judge Daniel P. Collins, made up the panel. Collins dissented.

The decision could impact separate but related lawsuits filed by interested parties in Texas along the U.S.-Mexico border.

In February 2019 several civil rights and environmentalist groups, including the American Civil Liberties Union, and the Sierra Club, sued the administration over the president’s emergency declaration to use billions in DoD funds for border walls along the U.S.-Mexico border.

Multiple lawsuits, filed in 2019 and 2020, argue that the president violated the U.S. Constitution by overstepping his executive authority and sidestepping Congress to fund wall construction along the southern border.

The panel also ruled that the Sierra Club’s lawsuit was a proper party to challenge the funds transfers, and concluded that Sierra Club had both a constitutional and an ultra vires cause of action, and could continue.

“Because the federal defendants not only exceeded their delegated authority, but also violated an express constitutional prohibition designed to protect individual liberties, the panel held that Sierra Club had a constitutional cause of action,” the court opinion stated. “Second, the panel held that the Sierra Club had an equitable ultra vires cause of action to challenge the Department of Defense’s transfer of funds. Where it is alleged that the Department of Defense has exceeded the statutory authority delegated by Section 8005, plaintiffs like Sierra Club can challenge this agency action.”

Just last month, the Center for Biological Diversity, a Tucson-based environmentalist group, filed a similar lawsuit challenging wall waivers filed in March 2020 that would speed-up construction for a border wall by waiving environmental laws that normally delay or stall the construction.

The lawsuit, filed by CBD, and the Animal Legal Defense Fund, in U.S. District Court in Washington, challenges the waivers that would affect land in California, Arizona, New Mexico and Texas.

Specifically, the lawsuit challenges the administration’s use of $7.2 billion from the Department of Defense to build the wall along the U.S.-Mexico border, arguing they did so without congressional approval.

After the ruling Friday, ACLU attorneys reacted to the panel’s decision.

“This ruling is a win for the rule of law, the environment, and border communities,” Dror Ladin, staff attorney with the ACLU’s National Security Project, said.

“President Trump’s xenophobic wall is already leveling protected lands, desecrating cultural sites, and destroying wildlife. There’s no undoing the damage that’s been done, but we will be back before the Supreme Court to finally put a stop to this destructive wall.”

Attorneys for Sierra Club said the ruling was “monumental” for border communities.

“The appeals court ruled against Trump’s unconstitutional wall construction. We should be protecting communities, our democracy, and the environment, not tearing these things apart as Trump hoped to do” Gloria Smith, managing attorney at the Sierra Club, said. “We rise with border communities to stop this administration from further inflicting its relentless agenda— harming the people and places we know and love.”

The case is likely to reach the Supreme Court, according to a release from the ACLU.