Image copyright Reuters Image caption Building the border wall was a major campaign promise by President Trump during the 2016 elections

US President Donald Trump has again been thwarted in his attempt to use military money to fund his wall along the border with Mexico.

On Saturday, he lodged an appeal against a ruling by a judge blocking him from using defence department funds for anti-drug activities.

But a panel of the US 9th Circuit Court of Appeals upheld the freeze, saying it was up to Congress to allocate funds.

Mr Trump declared a national emergency over the wall earlier this year.

He said he needed $6.7bn (£5.3bn) to it as a matter of national security.

Building the wall was a major election campaign promise.

Two of the three-judge panel in San Francisco agreed with the lower court's decision.

"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," the two judges wrote in their ruling.

In May, federal judge Haywood Gilliam temporarily blocked the use of defence department funds because it had not been approved by Congress.

About 20 states, along with groups including the American Civil Liberties Union (ACLU), have filed lawsuits to try to stop the president using the emergency declaration to bypass Congress.

Media playback is unsupported on your device Media caption Other presidents got money for a border barrier - why not Trump?

The border wall has been a major political battle for the president.

In February, Congress approved $1.38bn for the construction of "primary pedestrian fencing" along the Rio Grande Valley in Texas - far less than Mr Trump had sought.

His declaration of a national emergency was designed to unlock multi-billion dollar funding for the wall, including $2.5bn from the department of defence and $3.6bn from military construction projects.

That sum is still considerably short of the estimated $23bn cost of the barrier along almost 2,000 miles (3,200km) of border.

The House of Representatives is also taking legal action to stop the diversion of funds for the wall project.