WASHINGTON — A U.S. federal judge on Tuesday ruled against President Donald Trump's attempt to transfer $3.6 billion in military construction funds to build a wall on the U.S.-Mexico border.

In a 21-page opinion, El Paso, Texas-based U.S. District Court Judge David Briones issued a permanent injunction that prohibited the Trump administration from using the funds for border barriers.

The ruling is a legal setback for Trump, whose administration has vowed to build at least 450 miles of wall along the border by November 2020, when the U.S. presidential election will take place. Trump has argued the wall will deter illegal border crossings, a major focus of his presidency.

Download the NBC News app for breaking news and politics

Top Democrats in Congress have criticized the project as wasteful and ineffective. They've also ripped Trump for using billions in U.S. taxpayer dollars for the wall after he promised during his presidential campaign that Mexico would pay for it.

The Supreme Court ruled in July that the Trump administration could access a separate pot of $2.5 billion from a Pentagon counter-narcotics fund to pay for wall construction pending a related appeal - a major victory for Trump.

Acting Homeland Security Secretary Chad Wolf said during a Nov. 20 press conference in El Paso, Texas, that 83 miles of border wall had been built under Trump. He said another 153 miles of border wall are currently under construction.

"President Trump has been clear," Wolf said during the press conference. "We will build the wall, and he is following through on his promise."