A federal judge in Texas has ordered the Obama administration to halt plans to grant special immigration status to 4 to 5 million individuals who entered the United States illegally or overstayed their visas.

US District Judge Andrew Hanen issued a preliminary injunction late Monday to block federal officials from implementing programs that stem from President Obama’s executive action on immigration announced last November.

The judge said the executive branch was engaged in a “complete abdication” of statutory goals set by Congress.

“The government has pointed this Court to no law that gives [the Department of Homeland Security] such wide-reaching discretion to turn 4.3 million individuals from one day being illegally in the country to the next day having lawful presence,” the judge wrote.

Judge Hanen’s injunction effectively halts the expansion of the administration’s immigration program until the courts can examine whether it complies with regulatory procedures, federal immigration statutes, and the Constitution. Any appeal of the injunction will be directed to the Fifth US Circuit Court of Appeals in New Orleans, and perhaps, eventually, to the US Supreme Court.

Republicans in Congress have called the president’s unilateral immigration action illegal and unconstitutional. They have sought to block the effort legislatively through amendments to the Department of Homeland Security’s appropriations bill. That effort threatens to shut down funding to DHS on Feb. 27.

In the meantime, Texas and 25 other states filed suit in federal court in Brownsville, Texas, challenging the president’s actions.

Specifically, Hanen found the Obama administration had enacted a substantive government regulation without following the proper legal procedures, such as offering interested parties an opportunity to receive notice of the new rules and give comments.

The judge found that it was in the public interest to block the program before potentially millions of undocumented immigrants receive special immigration status and work permits as part of a government program that, he said, might later be declared illegal or unconstitutional.

“This Court finds that ... the public interest factor that weighs heaviest is ensuring that actions of the Executive Branch… comply with this country’s laws and its Constitution,” Hanen wrote in his 123-page opinion.

The White House pledged to appeal and overturn Hanen’s injunction.

“The district court’s decision wrongly prevents these lawful, commonsense policies from taking effect and the Department of Justice has indicated that it will appeal that decision,” White House spokesman Josh Earnest said.

Nancy Pelosi, Democratic leader in Congress, expressed confidence that the judge’s decision would be overturned on appeal.

“The president’s actions fall well within the clear constitutional and legal authority of his office, and the well-established precedent set by previous presidents,” she said in a statement.

Both House Speaker John Boehner (R) of Ohio and Senate majority leader Mitch McConnell (R) of Kentucky praised Hanen’s ruling.

“This ruling underscores what the president has already acknowledged 22 times: He doesn’t have the authority to take the kinds of actions he once referred to as ‘ignoring the law,’ and ‘unwise and unfair,’ ” Senator McConnell said.

In a televised speech on Nov. 20, the president said that since Congress failed to pass a comprehensive immigration reform bill, he would take action himself to extend deferred deportation status and grant work permits to up to 5 million of the estimated 11 million undocumented immigrants currently in the US.

Monday’s court action came less than two days before enrollment in the special immigration program was to begin on Wednesday.

Hanen did not rule on the question of whether the executive branch had acted unconstitutionally in making laws rather than executing them, as the state plaintiffs had argued. But he expressed significant concerns.

He rejected the administration’s broad assertion of prosecutorial discretion – the decision not to enforce a law. The administration’s immigration programs go beyond that, he said, to confer benefits to undocumented immigrants.

“Non-enforcement does not entail refusing to remove these individuals as required by the law and then providing three years of immunity from that law, legal presence status, plus any benefits that may accompany legal presence under current regulations,” the judge said.

“The DHS secretary is not just rewriting the laws; he is creating them from scratch,” Hanen said.

In their lawsuit, lawyers for the 26 states alleged that President Obama and his administration were violating the Constitution’s “take care” clause. Rather than “taking care” that laws passed by Congress are faithfully executed, the administration is rewriting immigration law by ignoring a congressional command that undocumented immigrants “shall” be deported, the suit says.

The suit also alleges that the administration violated the Administrative Procedures Act by failing to follow the required procedure for enacting new regulations. This includes offering notice to affected groups and individuals and an opportunity to comment on the proposed new regulation.

The program announced by the president on Nov. 20 was an expansion of a similar program created in 2012. The 2012 program, called Deferred Action for Childhood Arrivals (DACA), provided deferred deportation status and work permits to up to 1.2 million unauthorized immigrants who arrived in the US with their parents. Roughly 640,000 individuals have taken advantage of the program.

On Nov. 20, Mr. Obama created a new program for undocumented immigrants called Deferred Action for Parental Accountability (DAPA). It grants protected immigration status and work permits to the parents of a US citizen or lawful permanent resident. Estimates are that DAPA could benefit as many as 3.7 million individuals who are currently in the US without legal authorization. (Obama also expanded eligibility for DACA on Nov. 20, opening the program to an additional 300,000 undocumented immigrants.)

The administration and supportive legal experts say that both programs are well within the authority of the president.

They note US immigration law grants broad discretion to the executive branch, including the authority to decide how best to enforce federal statutes.

Administration officials say their priority is to focus scarce enforcement resources on deporting unauthorized immigrants who have committed crimes or otherwise pose a threat. At the same time, the administration is seeking to keep the families of unauthorized immigrants together, if possible.

In his order, Judge Hanen enjoined DHS and other government officials from implementing “any and all aspects or phases of” the DAPA program, as well as the expansion of the DACA program.

The judge’s ruling does not apply to individuals who are already participating in the DACA program.