OAKLAND, Calif. (AP) — A federal judge on Friday prohibited President Donald Trump from tapping $2.5 billion in military funding to build high-priority segments of his prized border wall in California, Arizona and New Mexico.

Judge Haywood S. Gilliam, Jr. in Oakland acted in two lawsuits filed by California and by activists who contended that the money transfer was unlawful and that building the wall would pose environmental threats.

“All President Trump has succeeded in building is a constitutional crisis, threatening immediate harm to our state,” said California Attorney General Xavier Becerra, who led a 20-state coalition of attorneys general in one lawsuit.

The American Civil Liberties Union, which sued on behalf of Sierra Club and Southern Border Communities Coalition, praised the decision.

“This decision upholds the basic principle that the president has no power to spend taxpayer money without Congress’ approval,” said ACLU staff attorney Dror Ladin. “We will continue to defend this core principle of our democracy.”

Speaking Saturday at a news conference marking the end of the Group of 20 summit in Osaka, Japan, Trump called the decision “a disgrace.”

“So we’re immediately appealing it and we think we’ll win the appeal,” he went on to say. “There was no reason that that should have happened. And a lot of wall is being built.”

The decisions are in line with Gilliam’s ruling last month that blocked work from beginning on two of the highest-priority projects — one spanning 46 miles (74 kilometers) in New Mexico and another covering 5 miles (8 kilometers) in Yuma, Arizona.

But the fight is far from over. The U.S. 9th Circuit Court of Appeals is expected to take up the same issue of using military money next week.

At issue is President Donald Trump’s February declaration of a national emergency so that he could divert $6.7 billion from military and other sources to begin construction of the wall, which could have begun as early as Monday.

Trump declared the emergency after losing a fight with the Democratic-led House that led to a 35-day government shutdown.