A federal judge in California on Friday issued a preliminary injunction barring the government from “taking any action” to construct a border wall in two sectors using funds diverted from the Defense Department.

Construction on the U.S.-Mexico border using money diverted from the Defense Department under President Donald Trump's emergency declaration was scheduled to begin as soon as Saturday, according to the American Civil Liberties Union, which had filed the lawsuit against the government.

"Congress's 'absolute' control over federal expenditures — even when that control may frustrate the desires of the Executive Branch regarding initiatives it views as important — is not a bug in our constitutional system. It is a feature of that system, and an essential one," U.S. District Judge Haywood S. Gilliam wrote in the ruling.

The order applies to two planned projects to add 51 miles of fence in two areas, the Associated Press reported.

"This order is a win for our system of checks and balances, the rule of law and border communities," Dror Ladin, staff attorney with the ACLU’s National Security Project, said in a statement.

The ACLU was acting as legal counsel on behalf of the Sierra Club and a coalition of border communities that had sued the government to block the funding.

Trump responded Saturday in a tweet calling Gilliam another "activist Obama appointed judge" and saying the ruling is "against Border Security and in favor of crime, drugs and human trafficking. We are asking for an expedited appeal."

Another activist Obama appointed judge has just ruled against us on a section of the Southern Wall that is already under construction. This is a ruling against Border Security and in favor of crime, drugs and human trafficking. We are asking for an expedited appeal! — Donald J. Trump (@realDonaldTrump) May 25, 2019

The president in February declared an emergency to divert billions of dollars from the Pentagon for a border wall. Trump made the move after Congress declined to approve the billions requested by the president. The federal government was partially shut down for 35 days — its longest in history — over Trump's demand for border wall funding.

Gilliam, of the U.S. District Court of Northern California in Oakland and an appointee of President Barack Obama, wrote in his order that the government’s position "would pose serious problems under the Constitution’s separation of powers principles."

He agreed with the plaintiffs challenging the move that "to permit this massive redirection of funds under these circumstances likely would amount to an 'unbounded authorization for Defendants to rewrite the federal budget.'"

Gilliam wrote that his order applied to construction in two sectors, identified as "Yuma Sector Project 1" and "El Paso Sector Project 1."

Emails seeking comment from two attorneys listed as representing the government in the case were not immediately returned Friday evening.

A spokesperson for the Department of Justice did not immediately return a request for comment Friday night.

The ACLU said Gilliam's decision affected the first-announced projects, which the organization said "amounted to $1 billion diverted from military pay and pension accounts."

"The case is not about whether the challenged border barrier construction plan is wise or unwise," the judge wrote, and "It is not about whether the plan is the right or wrong policy response to existing conditions at the southern border of the United States."

Gilliam said in his order that the Sierra Club and the Southern Border Communities Coalition showed a "likelihood of success" in arguing that Congress previously denied funding.

He wrote that the groups were also likely to show that the government fails to meet a required "unforeseen military requirement" for reprogramming funds.

The "argument that the need for the requested border barrier construction funding was 'unforeseen' cannot logically be squared with the Administration's multiple requests for funding for exactly that purpose dating back to at least early 2018," the judge said in his order.

Gilliam set a case management conference for June 5.