A US federal judge has issued a permanent injunction barring President Donald Trump's attempt to transfer $US3.6 billion in military construction funds to build a wall on the border with Mexico.
Judge David Briones, of US District Court in El Paso, Texas, issued the injunction in a 21-page ruling on Tuesday.
The ruling is a setback for Trump, whose administration has vowed to build at least 700 kilometres of wall along the border by November 2020, when the US presidential election will take place.
Trump has argued the wall will deter illegal border crossings, a major focus of his presidency.
A Justice Department spokesman said the administration will appeal the ruling.
Trump declared a national emergency last February in order to transfer funds from the Pentagon to build the wall after Congress refused to provide the level of funding he sought.
Top Democrats in Congress have criticised the project as wasteful and ineffective.
In the lawsuit, the plaintiffs, El Paso County and the Border Network for Human Rights, an El Paso-based immigration reform group, argued that Trump exceeded his authority when he declared the emergency and sought to redirect the funds.
Kristy Parker, counsel for Protect Democracy, an organisation that represented plaintiffs in the case, said in a statement that the order "affirms that the president is not a king and that our courts are willing to check him when he oversteps his bounds".
Briones ruled in October that the proclamation was unlawful and then asked the plaintiffs to file a proposed preliminary injunction.
He said in that ruling that the transfer of the military funds was unlawful because it went against the intent outlined by Congress in the spending bill it passed in January 2019.
Australian Associated Press