The administration argued that Mr. Obama was well within long-established federal authority for a president to decide how to enforce the immigration laws. But Texas and the other states said the executive measures were an egregious case of government by fiat that would impose huge new costs on their budgets.
In ordering the administration to suspend the programs while he makes a final decision on the case, Judge Hanen agreed with the states that the president's policies had already been costly for them.
"The court finds that the government's failure to secure the border has exacerbated illegal immigration into this country," Judge Hanen wrote. "Further, the record supports the finding that this lack of enforcement, combined with the country's high rate of illegal immigration, significantly drains the states' resources."
Ken Paxton, the attorney general of Texas, which is leading the states bringing the lawsuit, hailed the judge's ruling as a "victory for the rule of law in America and a crucial first step in reining in President Obama's lawlessness." He said Mr. Obama's actions were "an affront to everyone pursuing a life of freedom and opportunity in America the right way."
Mr. Obama said he was using executive powers to focus enforcement agents on deporting serious criminals and those posing threats to national security. Three-year deportation deferrals and work permits were offered for undocumented immigrants who have not committed serious crimes, have been here at least five years and have children who are American citizens or legal residents.
As part of the package, Homeland Security Secretary Jeh Johnson also established new priorities, instructing enforcement agents to concentrate on deporting the most dangerous criminals, including terrorists and gang members, as well as migrants caught crossing the border illegally.
More from the New York Times:
U.S. embedded spyware overseas, report claims
Killing in Washington State offers 'Ferguson' moment for Hispanics
Health care success for Midwest co-op proves its undoing
In his opinion, Judge Hanen accused administration officials of being "disingenuous" when they said the president's initiatives did not significantly alter existing policies. He wrote that the programs were "a massive change in immigration practice" that would affect "the nation's entire immigration scheme and the states who must bear the lion's share of its consequences." He said the executive actions had violated laws that the federal government must follow to issue new rules, and he determined "the states have clearly proven a likelihood of success on the merits."
Since the lawsuit was filed on Dec. 3, the stark divisions over Mr. Obama's sweeping actions have played out in filings in the case. Three senators and 65 House members, all Republicans, signed a legal brief opposing the president that was filed by the American Center for Law and Justice, a conservative legal action organization.
Joe Arpaio, the sheriff of Maricopa County in Arizona, who is known for crackdowns on people living in the country illegally, also filed a brief supporting the states' lawsuit. In December, a federal judge in Washington dismissed a separate lawsuit by Sheriff Arpaio seeking to stop the president's actions.
On the other side, Washington and 11 other states as well as the District of Columbia weighed in supporting Mr. Obama, arguing that they would benefit from the increased wages and taxes that would result if illegal immigrant workers came out of the underground. The mayors of 33 cities, including New York and Los Angeles, and the Conference of Mayors also supported Mr. Obama.
"The strong entrepreneurial spirit of immigrants to the United States has significantly boosted local economies and local labor markets," the mayors wrote in their filing.
Some legal scholars said any order by Judge Hanen to halt the president's actions would be quickly suspended by the United States Court of Appeals for the Fifth Circuit in New Orleans.
"Federal supremacy with respect to immigration matters makes the states a kind of interloper in disputes between the president and Congress," said Laurence H. Tribe, a professor of constitutional law at Harvard. "They don't have any right of their own."
The states' lawsuit quotes Mr. Obama as saying many times in recent years that he did not have authority to take actions as broad as those he ultimately took. Mr. Tribe said that argument was not likely to pass muster with appeals court judges.
"All of that is interesting political rhetoric," he said, "but it has nothing to do with whether the states have standing and nothing to do with the law."
Judge Hanen, who was appointed in 2002 by President George W. Bush, has excoriated the Obama administration's immigration policies in several unusually outspoken rulings. The president's supporters have said that Texas officials, who are leading the states' lawsuit, were venue shopping when they chose to file in Brownsville.
But at a hearing on Jan. 15, Judge Hanen said Brownsville, which sits on the border with Mexico, was an appropriate venue for the suit because its residents see the impact of immigration every day. "Talking to anyone in Brownsville about immigration is like talking to Noah about the flood," Judge Hanen said.
Read MorePoliticians and industry respond to Obama's immigrationannouncement
In a lengthy and colorful opinion last August, Judge Hanen departed from the issue at hand to accuse the Obama administration of adopting a deportation policy that "endangers America" and was "an open invitation to the most dangerous criminals in society."
The case involved a Salvadoran immigrant with a long criminal record whom Judge Hanen had earlier sent to prison for five years. Instead of deporting the man after he served his sentence, an immigration judge in Los Angeles ordered him released, a decision Judge Hanen found "incredible." Citing no specific evidence, he surmised that the administration had adopted a broader policy of releasing such criminals.
While acknowledging that he had no jurisdiction to alter policy, Judge Hanen said he relied on his "firsthand, in-the-trenches knowledge of the border situation" and "at least a measurable level of common sense" to reach his conclusions about the case.
"The court has never been opposed to accommodating those who come to this country yearning to be free, but this current policy only restricts the freedom of those who deserve it most while giving complete freedom to criminals who deserve it least," he wrote.
The mayor of Brownsville, Tony Martinez, was among those who filed court papers supporting Mr. Obama's actions. "We see a tremendous value in families staying together and being together," Mr. Martinez said on a conference call on Tuesday organized by the White House. "Eventually we hope to get all these folks out of the shadows," he said.