FILE PHOTO: A child looks through the bars of a wall from the side of Ciudad Juarez, Mexico, in this picture taken on the side of El Paso, Texas, U.S. May 25, 2019. REUTERS / Jose Luis Gonzalez/File Photo

(Reuters) - U.S. President Donald Trump on Saturday appealed a U.S. judge’s ruling that blocked his administration from using $2.5 billion in funds intended for anti-drug activities to construct a wall along the southern border with Mexico.

U.S. Department of Justice lawyers said in a court filing that they were formally appealing Friday’s ruling to the 9th U.S. Circuit Court of Appeals.

“[W]e’re immediately appealing it, and we think we’ll win the appeal,” Trump said during a press conference on Saturday at a summit of leaders of the Group of 20 (G20) major economies in Japan.

“There was no reason that that should’ve happened,” Trump said.

Trump says construction of a wall along the U.S.-Mexico border is needed to keep out illegal immigrants and drugs, but he has so far been unable to get congressional approval to do so.

In February, the Trump administration declared a national emergency to reprogram $6.7 billion in funds that Congress had allocated for other purposes to build the wall, which groups and states including California had challenged.

On Friday, U.S. District Court Judge Haywood Gilliam in Oakland, California said in a pair of court decisions that the Trump administration’s proposal to transfer Defense Department funds intended for anti-drug activities was unlawful.

One of Gilliam’s rulings was in a lawsuit filed by California on behalf of 20 states, while the other was in a case brought by the American Civil Liberties Union in coordination with the Sierra Club and the Southern Border Communities Coalition.

“These rulings critically stop President Trump’s illegal money grab to divert $2.5 billion of unauthorized funding for his pet project,” California Attorney General Xavier Becerra said in a statement late on Friday. “All President Trump has succeeded in building is a constitutional crisis, threatening immediate harm to our state.”