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.