Image copyright AFP Image caption The border wall - or barrier - was President Trump's major campaign promise during the 2016 elections

A US federal judge has temporarily blocked the use of defence department funds to build a border wall between the US and Mexico.

The judge granted the injunction to block the use of $1bn (£786m) in Arizona and Texas because it had not been approved by Congress.

President Donald Trump declared an emergency earlier this year, saying he needed $6.7bn to build the wall as a matter of national security.

It was a major campaign promise.

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.

What did the judge say?

"The position that when Congress declines the executive's request to appropriate funds, the executive nonetheless may simply find a way to spend those funds 'without Congress' does not square with the fundamental separation of powers principles dating back to the earliest days of our Republic," Judge Haywood Gilliam said in his ruling.

He said plaintiffs were likely to show that administration officials "exceeded their statutory authority, and that irreparable harm will result from those actions".

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

Construction was due to begin as early as this weekend in the two states.

However, despite the ruling President Trump could still find funds from elsewhere to build the wall, CNN reports.

The ACLU wrote on Twitter: "This is a win for our system of checks and balances, the rule of law and border communities."

What's the background?

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.