Donald Trump had declared an emergency to bypass Congress and get funds for border wall project. (File)

The Trump administration must temporarily halt the use of some Defense Department funds for a border wall with Mexico, a judge ruled on Friday, because the money was not specifically authorized by Congress for construction of the barrier.

The order blocks the use of $1 billion from the Department of Defense in Arizona and Texas, out of $6.7 billion that Trump administration said it planned to direct toward building the wall.

"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," Haywood Gilliam Jr, a US judge in California, wrote in the order.

Separately, Gilliam denied a preliminary injunction against the border wall sought by a coalition of sixteen states, but said they could move forward with their case.

Spokespeople for the Department of Homeland Security, Pentagon and the White House did not immediately respond to requests for comment.

Trump has said the wall is needed to address a crisis of drugs and crime flowing across the border into the United States.

The ruling adds to Trump's frustrations with federal court orders blocking his initiatives for cutting illegal immigration, a policy area he will focus on in his 2020 re-election bid.

In February, after a protracted political battle and a government shutdown, Congress approved $1.38 billion for construction of "primary pedestrian fencing" along the border in southeastern Texas, well short of Trump's demands.

To obtain the additional money, Trump declared a national emergency and his administration said it planned to divert $601 million from a Treasury Department forfeiture fund, $2.5 billion earmarked for Department of Defense counternarcotics programs and $3.6 billion from military construction projects.

The House of Representatives, more than a dozen states and two advocacy groups asked US District Court Judge Haywood Gilliam in Oakland, California to block the transfer of funds to prevent the wall construction.

They argue the administration cannot use funds Congress has specifically denied and cannot construct a barrier that was not authorized, nor can the administration work outside the geographic area identified by Congress.

"This is a win for our system of checks and balances, the rule of law, and border communities," the American Civil Liberties Union tweeted.

The wall funding faced another court challenge on Thursday, in a case brought by the House of Representatives in a federal court in the District of Columbia. The lawmakers have said the diversion of $6.1 billion in Defense Department funds violates the separation of powers doctrine laid out in the US Constitution.