PHOENIX — A federal appeals court has ruled the Trump administration illegally diverted $2.5 billion in military construction funds to finance the border wall through Arizona, California and New Mexico.

In a pair of 2-1 decisions Friday, the 9th U.S. Circuit Court of Appeals said the president “lacked independent constitutional authority’’ to authorize the transfer of the dollars.

“These funds were appropriated for other purposes, and the transfer amounted to drawing funds from the Treasury without authorization by statute and thus violating the Appropriations Clause,’’ Chief Judge Sidney Thomas wrote for himself and Judge Kim Wardlaw.

Thomas acknowledged that Congress did give the Department of Defense the authority to transfer money to respond to an “unforeseen military requirement.’’ But he said that was not the situation here.

“The border wall was not an unforeseen military requirement,’’ Thomas said. And he noted that Congress actually had refused to provide the funds.

And the judge said allowing the administration to move money around in this fashion essentially would incentivize the defense department to submit budget requests after it has submitted its final budget to Congress “in order to skirt the congressional appropriations process.’’

Only Judge Daniel Collins dissented, saying the transfers were lawful.

The net effect of the ruling, however, is less clear.

Last year the U.S. Supreme Court, on a 5-4 vote, agreed to let the administration start spending the cash while the cases were making their way through the courts. And just last month, the government awarded a $1.3 billion contract for a 42-mile section of the wall in Arizona.

Dan Mills, borderlands program manager for the Sierra Club Grand Canyon Chapter, acknowledged that, given the Supreme Court action, construction can continue while the Trump administration appeals. He said that includes stretches through the Organ Pipe Cactus National Monument and the San Bernadino National Wildlife Refuge in Cochise County.

That raises the possibility that, depending on how quickly this case goes back to the nation’s high court, the victory on Friday could prove moot.

“It would be devastating for Southern Arizona,’’ Mills said. “There would be a wall across the Santa Cruz River.’’

California Attorney General Xavier Becerra said the ruling “reminded the president — once again — that no one is above the law.’’

“While the Trump administration steals public funds to build an unauthorized wall at the southern border, families across the country are struggling to pay their bills,’’ he said in a prepared statement.

There was no immediate response from either the Department of Homeland Security or the Department of Defense, both of which were named as defendants.

But state Rep. Mark Finchem, R-Oro Valley, whose House Committee on Federal Relations hired attorneys to defend the wall, blasted the decision.

“That is interference of the courts with the power that the president has been given to act as the executive of the nation,’’ he told Capitol Media Services.

He said that Trump, charged with protecting national security, has the power to move around those dollars, especially after the Democrat-controlled Congress refused to act — a refusal Finchem said is based on the party’s desire to keep immigration alive as a campaign issue. And he defended the committee’s decision to intercede to defend the president’s decision.

“The state has an interest in this,’’ Finchem said.

“It’s our border,’’ he continued. “And we’re the ones responsible for managing what happens inside of our border.

Finchem represents Legislative District 11, which includes Marana, Picacho, Arizona City and Maricopa in Pinal County.

Rep. Mark Finchem

Rep. Mark Finchem, R-Oro Valley, represents much of Pinal County but not the Florence area.

On the other side of the issue, attorneys for the Tohono O’odham Nation argued that construction of a new section of the wall in the Tucson sector would not just cause environmental damage but actually would result in more criminal activity, trash, debris, damage to cultural resources and wildland fires caused by migrants as they effectively would end up there to avoid the fence.

The judges accepted similar arguments advanced by attorneys for several states — not including Arizona — who had filed their own challenge. And they said that California and New Mexico “demonstrated that border wall construction injures their quasi-sovereign interests by preventing them from enforcing their environmental laws.’’

In seeking to block the action, much of the brief filed by Finchem’s committee claimed the Sierra Club lacked legal standing to sue in the first place.

The court didn’t see it that way, with Thomas noting that thousands of the club’s members live near and frequently visit the areas along the border.

“They obtain recreational, professional, scientific, educational and aesthetic benefits from their activities in these areas, and from the wildlife dependent upon the habitat in these areas,’’ he wrote. “The construction of a border wall and related infrastructure will acutely injure these interests because the Department of Homeland Security is proceeding with border wall construction without ensuring compliance with any federal or state environmental regulations designed to protect these interests.’’

Finchem was angered at the decision to let the Sierra Club sue. And he was particularly miffed that taxpayers could end up paying the organization’s legal fees.

“The unrestricted use of taxpayer dollars to pay for the Sierra Club to sue the taxpayers is never what the Equal Access to Justice Act was about,’’ Finchem said. That law says a prevailing party in a legal action against the federal government is entitled to its legal fees unless the federal agency shows that its position “was substantially justified.’’

And Finchem, who is in running to become the speaker of the House, lashed out at members of Congress who he said were “standing in the way of the president doing his job.’’

“Imagine how much more effective the president would have been had these ‘resist’ bozos not been running around doing everything they can to interfere with the operations of our government,’’ he said. It was that lack of cooperation, Finchem said, that forced Trump to find “alternative means’’ of getting funds for the wall.

“The fact that money was taken away from some Democrat congressman’s district in the form of a military contract to move the money into some other national defense purpose, I guess they should have thought about that before they voted against building the wall which, by the way 78 percent of Americans want,’’ Finchem said.