President Donald Trump visits the US-Mexico border fence in Otay Mesa, California on September 18, 2019.

Nicholas Kamm | AFP | Getty Images

A federal judge ruled Friday that President Donald Trump violated federal law when he used his declaration of a national emergency to get millions for building a wall on the southern border.

The ruling is a victory for El Paso County, Texas, and the Border Network for Human Rights, which sued to stop border construction in their community. They argued that Trump had no legal authority to spend more than what Congress appropriated for the wall project.

In January the president asked for $5.7 billion to build "a steel barrier for the Southwest border," but Congress approved only $1.375 billion. In February, Trump declared a national emergency and ordered that money for Pentagon construction projects would be used instead for the wall.

Federal District Court Judge David Briones said the president's order violated a provision of the budget law approved by Congress which said "none of the funds made available in this or any other appropriation may be used to increase" the funding for the wall project.

"The president's proclamation is unlawful," Briones wrote.

He gave El Paso County and the Border Network ten days to file a proposed injunction that would give legal effect to his ruling and block any further use of military construction money for building the border wall.

Kristy Parker, a lawyer for Project Democracy, which represented the challengers, praised the ruling and said it "vindicates the Founders' wisdom and confirms that the president is not a king, and that he cannot override Congress's power to decide how to appropriate funds."

The judge's ruling does not effect a separate part of the emergency declaration, directing the Pentagon to transfer $2.5 billion in counterdrug money to the border project. The U.S. Supreme Court earlier this year declined to stop the use of that money for wall construction.

The Trump administration is sure to appeal Friday's ruling.