(CNN) A federal judge in California ruled against the Trump administration on Friday in two different cases, ultimately preventing $2.5 billion in federal funds from being used for a border wall in portions of California, New Mexico and Arizona.

In the first case, US District Court for Northern California ruled in favor of a challenge to President Donald Trump's attempt to move billions from the Defense Department budget toward building a border wall in El Centro, California, and New Mexico.

Trump's move was done as part of his national emergency declaration in February.

California Attorney General Xavier Becerra -- who has led a group of states in a separate lawsuit against the administration's push for border wall funding -- celebrated the decision Friday, which he said permanently stops the administration from proceeding with construction on the wall.

"These rulings critically stop President Trump's illegal money grab to divert $2.5 billion of unauthorized funding for his pet project," Becerra said. "All President Trump has succeeded in building is a constitutional crisis, threatening immediate harm to our state. President Trump said he didn't have to do this and that he would be unsuccessful in court. Today we proved that statement true."

Read More