A Texas federal judge on Tuesday blocked the Trump administration from diverting $3.6 billion in funds that were allocated by Congress for military construction projects to help pay for President Donald Trump’s long-promised southern border wall.

El Paso U.S. District Judge David Briones, appointed by then-President Bill Clinton in 1994, ruled that the Trump administration’s use of an emergency declaration last February to divert the money is unlawful. Congress is granted sole authority to appropriate taxpayer funds by the Constitution of the United States.

The judge however said the Trump administration is within its legal right to divert $2.5 billion intended for drug interdiction efforts to border wall construction.

“The President’s emergency proclamation was a blatant attempt to grab power from Congress,” Protect Democracy lawyer Kristy Parker said in a statement. “Today’s order affirms that the President is not a king and that our courts are willing to check him when he oversteps his bounds.”

Protect Democracy is a nonpartisan organization representing the plaintiff, El Paso County and the Border Network for Human Rights, which argued that the Trump administration overstepped its authority by “declaring a national emergency and violating the laws of Congress limiting funds for barriers at the United States-Mexico border.”

El Paso County also argued in court that it was suffering damage to its reputation and unfair economic harm due to the border wall project because Trump’s emergency declaration made it appear as if the border city is dangerous. Briones said that ruling has merit in another decision that came down in October.

House Speaker Nancy Pelosi, D-Calif., praised the judge’s decision (of course), accusing the president of attempting to subvert the separation of power among two of the three branches of the U.S. government.

“Once again, the courts have resoundingly ruled against the President’s attempt to negate our system of separation of powers, which is the genius of our Constitution, by assaulting Congress’s exclusive constitutional power of the purse,” Pelosi said via a statement.