A federal judge on Tuesday night rejected an Arizona sheriff's lawsuit seeking to halt President Barack Obama's plan to spare nearly 5 million people from deportation.

Refusing to rule on the merits of the case, U.S. District Judge Beryl Howell said the role of courts is not to engage in policymaking that is better left to the political branches of government.

The case brought by Maricopa County Sheriff Joe Arpaio "raises important questions regarding the impact of illegal immigration on this nation, but the questions amount to generalized grievances which are not proper for the judiciary to address," Howell wrote.

The sheriff filed a notice of appeal saying that he will pursue the case in the U.S. Court of Appeals for the District of Columbia Circuit.

White House spokesman Eric Schultz said the court correctly dismissed the lawsuit.

"Judge Howell's decision today confirms what the Department of Justice and scholars throughout the country have been saying all along: the president's executive actions on immigration are lawful," Schultz said. "The Supreme Court and Congress have made clear that federal officials can set priorities in enforcing our immigration laws, and the actions announced by the president are consistent with those taken by administrations of both parties for the last half century."

In the first courtroom battle over Obama's plan, Arpaio's lawyer Larry Klayman said Monday that the president violated the Constitution by doing an end-run around Congress. He argued that the program would let more immigrants enter the country illegally, burdening law enforcement as some commit crimes.

"It's not policy, he's creating law and he cannot do that under the U.S. Constitution," Klayman said of Obama.

In Monday's courtroom argument, Justice Department lawyer Kathleen Hartnett said Arpaio's lawsuit seemed to be raising a "political dispute" rather than a legal claim the court could address -- a position which Howell subsequently embraced in her decision.

Arpaio has often clashed with the federal government over the enforcement of immigration laws and he has filed suit to stop new policies announced by Obama. He claims that more than 35 percent of immigrants living in Maricopa County illegally who wound up in Arpaio's jails in 2014 were repeat offenders, signifying in the sheriff's view that federal officials have done a poor job of deporting criminals.

Under the program, the Homeland Security Department would prioritize the removal of immigrants who present threats to national security, public safety or border security.

At issue in the current dispute is the executive branch's use on a massive scale of an enforcement tool known as "deferred action" to implement enforcement policies and priorities.

In the context of the immigration laws, deferred action represents a decision by the Homeland Security Department not to seek the removal of an immigrant for a set period of time.

Even an ongoing threat to Arpaio by undocumented immigrants would not provide him with standing to challenge the deferred action programs at issue, Howell wrote. "The plaintiff must not only show that he is injured, but that the plaintiff's injury is fairly traceable to the challenged deferred action programs and that the injury is capable of redress by this court in this action."

In a separate lawsuit, Texas and 23 other states allege that Obama overstepped his constitutional powers in a way that will only worsen the humanitarian problems along the southern U.S. border. That suit is pending in a federal district court in Brownsville.