The ruling, from Judge James Munley, came after a nine-day trial held in March. He said in the 206-page opinion that the city's law was pre-empted by federal law and would violate due process, according to the Associated Press.
"Whatever the frustrations ... the city of Hazleton may feel about the current state of federal immigration enforcement, the nature of the political system in the United States prohibits the city from enacting ordinances that disrupt a carefully drawn federal statutory scheme," Munley wrote.
"Even if federal law did not conflict with Hazleton's measures, the city could not enact an ordinance that violates rights the Constitution guarantees to every person in the United States, whether legal resident or not," he wrote.
Hazleton's Republican Mayor Lou Barletta pushed for the ordinances last summer after two illegal immigrants were charged in a fatal shooting.
Barletta said the city of 30,000 would likely appeal the ruling, Reuters reported.
"I believe both sides realized this wasn't going to be the last day," he told CNN. "This small city isn't ready to stop fighting yet."
Dozens of towns and cities across the country have passed similar laws, but Witold Walczak, legal director of the American Civil Liberties Union of Pennsylvania, which represented the plaintiffs, said the ruling should freeze those efforts.
"This decision should be a blaring red stoplight for local officials thinking of copying Hazleton's misguided and unconstitutional law," he said, reported the AP.