SAN DIEGO (AP) — An appeals court on Wednesday upheld a freeze on Pentagon money to build a border wall with Mexico, casting doubt on President Donald Trump's ability to make good on a signature campaign promise before the 2020 election.

A divided three-judge panel of the 9th U.S. Circuit Court of Appeals in San Francisco agreed with a lower court ruling that prevented the government from tapping Defense Department counterdrug money to build high-priority sections of wall in Arizona, California and New Mexico.

The decision is a setback for Trump's ambitious plans. He ended a 35-day government shutdown in February after Congress gave him far less than he wanted. He then declared a national emergency that the White House said would free billions of dollars from the Pentagon.

The case may still be considered, but the administration cannot build during the legal challenge.

"As for the public interest, we conclude that it is best served by respecting the Constitution's assignment of the power of the purse to Congress, and by deferring to Congress's understanding of the public interest as reflected in its repeated denial of more funding for border barrier construction," wrote Judges Michelle Friedland, a Barack Obama appointee, and Richard Clifton, a George W. Bush appointee.

A freeze imposed by U.S. District Judge Haywood Gilliam Jr. of Oakland in May prevented work on two Pentagon-funded wall contracts — one spanning 46 miles (74 kilometers) in New Mexico and another covering 5 miles (8 kilometers) in Yuma, Arizona.

19 PHOTOS Migrants in Tijuana trickling over and under the border wall See Gallery Migrants in Tijuana trickling over and under the border wall Honduran migrant Joel Mendez, 22, passes his eight-month-old son Daniel through a hole under the U.S. border wall to his partner, Yesenia Martinez, 24, who had already crossed in Tijuana, Mexico, Friday, Dec. 7, 2018. Moments later Martinez surrendered to waiting border guards while Mendez stayed behind in Tijuana to work, saying he feared he'd be deported if he crossed. (AP Photo/Rebecca Blackwell) Central American migrants planning to surrender to U.S. border patrol agents climb over the U.S. border wall from Playas de Tijuana, Mexico, late Monday, Dec. 3, 2018. Thousands of migrants are living in crowded tent cities in the Mexican city of Tijuana after undertaking a grueling, weeks-long journey to the U.S. border. (AP Photo/Rebecca Blackwell) In a photo taken from Playas of Tijuana, Mexico, Honduran migrants climb over a section of the U.S. border fence before handing themselves in to border control agents, Sunday, Dec. 2, 2018. A steady trickle of Central American migrants have been finding ways to climb over, tunnel under or slip through the U.S. border wall to plant their feet on U.S. soil and ask for asylum. (AP Photo/Rebecca Blackwell) Honduran migrants who jumped the border wall to the U.S. side, help other members of their families to jump the wall, in Tijuana, Mexico, Sunday, Dec. 2, 2018. Thousands of migrants who traveled via caravan are seeking asylum in the United States, but face a decision between waiting months or crossing illegally, because the U.S. government only processes a limited number of cases a day at the San Ysidro border crossing in San Diego. (AP Photo/Ramon Espinosa) Honduran migrant Joel Mendez, 22, feeds his eight-month-old son Daniel as his partner Yesenia Martinez, 24, crawls through a hole under the U.S. border wall, in Tijuana, Mexico, Friday, Dec. 7, 2018. Moments later Martinez surrendered to waiting border guards while Mendez stayed behind in Tijuana to work, saying he feared he'd be deported if he crossed. (AP Photo/Rebecca Blackwell) Yesenia Martinez, 24, carries her eight-month-old son Daniel as she looks for a place to cross the U.S. border wall to surrender to border patrol and request asylum, in Tijuana, Mexico, Friday, Dec. 7, 2018. Martinez surrendered to waiting border guards while her partner Joel Mendez stayed behind in Tijuana to work, saying he feared he'd be deported if he crossed. (AP Photo/Rebecca Blackwell) A woman climbs the U.S. border wall, planning to surrender to U.S. Border Patrol agents and apply for asylum, as she crosses from Playas de Tijuana, Mexico, Monday, Dec. 3, 2018. Often within minutes, border guards quickly arrive to escort migrants to detention centers and begin "credible fear" interviews. (AP Photo/Rebecca Blackwell) A woman holding a baby peers through the U.S. border fence as she tries to reach a point where scores of migrants have been crossing in recent days, now blocked by private security, in Playas de Tijuana, Mexico, Wednesday, Dec. 5, 2018. Legal groups argue that federal law states that immigrants can apply for asylum no matter how they enter U.S. territory. (AP Photo/Rebecca Blackwell) Honduran migrant Leivi Ortega, 22, wearing a rosary, looks at her phone while she, her partner and their young daughter, wait in hopes of finding an opportunity to cross the U.S. border from Playas de Tijuana, Mexico, Wednesday, Dec. 5, 2018. In early December, U.S. Customs and Border Protection said that the San Diego sector experienced a "slight uptick" in families entering the U.S. illegally with the goal of seeking asylum. (AP Photo/Rebecca Blackwell) Yesenia Martinez, 24, reaches back from the San Diego, California side of the U.S. border wall to get her baby's bottle, after crossing underneath from Tijuana, Mexico, Friday, Dec. 7, 2018. Martinez is among a wave of Central Americans getting past the imposing barrier between Mexico and California and expediting their asylum claims by readily handing themselves over to U.S. agents. (AP Photo/Rebecca Blackwell) A Honduran migrant helps a young girl cross to the American side of the border wall, in Tijuana, Mexico, Sunday, Dec. 2, 2018. In November, President Donald Trump issued a proclamation suspending asylum rights for people who try to cross into the U.S. illegally from Mexico, although a divided U.S. appeals court has refused to immediately allow the Trump administration to enforce the ban. (AP Photo/Ramon Espinosa) Salvadoran migrant Cesar Jobet, right, and Daniel Jeremias Cruz hide from U.S. border agents after they dug a hole in the sand under the border wall and crossed over to the U.S. side, in Playas de Tijuana, Mexico, Friday, Nov. 30, 2018. When the two youths were detected by agents they ran back to the Mexican side. (AP Photo/Ramon Espinosa) A Honduran migrant walks with his son in his arms after jumping the U.S. border wall with plans to turn himself over to U.S. border patrol agents in order to apply for asylum, seen from Tijuana, Mexico, Thursday, Nov. 29, 2018. In twos or threes, or sometimes by the dozen, migrants arrive at the U.S. border wall and manage to cross over. (AP Photo/Ramon Espinosa) A Honduran migrant walks with his son in his arms after jumping the wall to the U.S that separates Tijuana, Mexico and San Diego, in Tijuana, Mexico, Thursday, Nov. 29, 2018. Aid workers and humanitarian organizations expressed concerns Thursday about the unsanitary conditions at the sports complex in Tijuana where more than 6,000 Central American migrants are packed into a space adequate for half that many people and where lice infestations and respiratory infections are rampant. (AP Photo/Ramon Espinosa) A Honduran migrant walks with his son in his arms after jumping the wall to the U.S that separates Tijuana, Mexico and San Diego, in Tijuana, Mexico, Thursday, Nov. 29, 2018. Aid workers and humanitarian organizations expressed concerns Thursday about the unsanitary conditions at the sports complex in Tijuana where more than 6,000 Central American migrants are packed into a space adequate for half that many people and where lice infestations and respiratory infections are rampant. (AP Photo/Ramon Espinosa) A Honduran migrant walks after jumping the wall to the U.S that separates Tijuana, Mexico and San Diego, in Tijuana, Mexico, Thursday, Nov. 29, 2018. Aid workers and humanitarian organizations expressed concerns Thursday about the unsanitary conditions at the sports complex in Tijuana where more than 6,000 Central American migrants are packed into a space adequate for half that many people and where lice infestations and respiratory infections are rampant. (AP Photo/Ramon Espinosa) In a photo taken from the Tijuana, Mexico, side of the border wall, a guard on the U.S. side, at left, watches Honduran migrants jump the wall into the United States, Sunday, Dec. 2, 2018. Thousands of migrants who traveled via caravan are seeking asylum in the U.S., but face a decision between waiting months or crossing illegally, because the U.S. government only processes a limited number of cases a day at the San Ysidro border crossing in San Diego. (AP Photo/Ramon Espinosa) In a photo taken from the Tijuana, Mexico, side of the border, two immigrants on U.S. soil try to jump the second wall before border police arrived and arrested them, Sunday, Dec. 2, 2018. Thousands of migrants who traveled via caravan are seeking asylum in the U.S., but face a decision between waiting months or crossing illegally, because the U.S. government only processes a limited number of cases a day at the San Ysidro border crossing in San Diego. (AP Photo/Ramon Espinosa) In a photo taken from the Tijuana, Mexico, side of the border wall, a U.S. Border Patrol agent is seen as Honduran migrants who jumped the wall surrender on the U.S. side, Sunday, Dec. 2, 2018. Thousands of migrants who traveled via caravan are seeking asylum in the U.S., but face a decision between waiting months or crossing illegally, because the U.S. government only processes a limited number of cases a day at the San Ysidro border crossing in San Diego. (AP Photo/Ramon Espinosa) Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

While the order applied only to those first-in-line projects, Gilliam made clear that he felt the American Civil Liberties Union, which sued on behalf of the Sierra Club and Southern Border Communities Coalition, was likely to prevail in their argument that Trump ignored Congress' wishes by diverting Defense Department money.

Gilliam went a step further Friday by ruling definitively that the administration couldn't use Pentagon counterdrug money for the two projects covered in his May order or to replace 63 miles (101 kilometers) in the Border Patrol's Tucson, Arizona, sector and 15 miles (24 kilometers) in its El Centro, California, sector.

The administration immediately appealed.

N. Randy Smith, a George W. Bush appointee, strongly disagreed with the appeals court ruling, saying it misread constitutional separation of powers.

"The majority here takes an uncharted and risky approach — turning every question of whether an executive officer exceeded a statutory grant of power into a constitutional issue," he wrote in his dissent. "This approach is in contradiction to the most fundamental concepts of judicial review."

The Justice Department didn't immediately respond to a request for comment Wednesday. Its attorneys argued that the freeze on Pentagon funds showed a "fundamental misunderstanding of the federal appropriations process."

At stake is billions of dollars that would allow Trump to make progress on a major 2016 campaign promise heading into his race for a second term.

Trump declared a national emergency after losing a fight with the Democratic-led House that led to the 35-day shutdown. Congress agreed to spend nearly $1.4 billion on barriers in Texas' Rio Grande Valley, the busiest corridor for illegal crossings, which was well below the $5.7 billion the president requested.

Trump grudgingly accepted the money but declared the emergency to siphon cash from other government accounts, finding up to $8.1 billion for wall construction. The money includes $3.6 billion from military construction funds, $2.5 billion from Defense Department counterdrug activities and $600 million from the Treasury Department's asset forfeiture fund.

Acting Defense Secretary Mark Esper has yet to approve transferring the military construction funds. The Treasury Department funds have so far survived legal challenges.

The president's adversaries say the emergency declaration was an illegal attempt to ignore Congress.

The administration said the U.S. needed emergency protection to fight drug smuggling. Its arguments did not mention illegal immigration or unprecedented numbers of Central American families seeking asylum at the U.S. border , which have dominated public attention in recent months.

The administration has awarded $2.8 billion in contracts for barriers covering 247 miles (390 kilometers), with all but 17 miles (27 kilometers) of that to replace existing barriers not expand coverage. It is preparing for a flurry of construction that the president is already celebrating at campaign-style rallies.

Trump inherited barriers spanning 654 miles (1,046 kilometers), or about one-third of the border with Mexico. Of the miles covered under Trump-awarded contracts, more than half is with Pentagon money.

The Army Corps of Engineers recently announced several large Pentagon-funded contacts.

SLSCO Ltd. of Galveston, Texas, won a $789 million award to replace the New Mexico barrier. Southwest Valley Constructors of Albuquerque, New Mexico, won a $646 million award for the work in Tucson. Barnard Construction Co. of Bozeman, Montana, won a $141.8 million contract to replace barrier in Yuma and El Centro.

More from :

Fotis Dulos, husband of missing Connecticut mother, fiercely defends his innocence

Navy SEAL acquitted of murder in killing of captive in Iraq

Supremacist gets life sentence on federal hate crime charges in Charlottesville attack