A Pennsylvania judge ruled on Tuesday that Pittsburgh's recently passed gun-control measures violate state law.

In his ruling, Allegheny County judge Joseph M. James said the city's ordinances were in plain opposition to a state preemption law which prohibits localities from passing their own gun laws.

"The Uniform Firearms Act is a comprehensive statute that evidences an intent by the Legislature to preempt the entire field of firearms and ammunition across the state of Pennsylvania," Judge James wrote.

The Pittsburgh ordinances restricted the use of certain rifles, like the AR-15, within city limits, banned the use of magazines which hold more than 10 rounds, and creates a process to confiscate firearms from those accused of being a threat to themselves or others. They were passed in the wake of the mass shooting at the Tree of Life Synagogue last year, which took the lives of 11 people.

The gun-control ordinances faced immediate opposition from gun-rights activists, who launched several lawsuits. A suit filed by Pennsylvania-based Firearm Owners Against Crime, three Pennsylvania residents, the Firearm Policy Coalition, and the Firearm Policy Foundation led to the judge's decision. The groups applauded James's ruling.

"I am delighted that Judge James' decision today appropriately struck down the City of Pittsburgh's unlawful firearm ordinances and signage," plaintiffs' attorney Joshua Prince said in a statement. "The City's gun control sought to eviscerate the inviolate right of the residents of the Commonwealth to keep and bear arms and ensnare law-abiding citizens through a patchwork of laws. Today, Judge James made clear that Mayor Peduto and the Pittsburgh City Council are neither above the law nor a special class of citizens that may violate the law with impunity."

The National Rifle Association called the decision a "great day for law-abiding Pennsylvania gun owners."

"This is a huge victory for law-abiding gun owners and everyone who values freedom in the Keystone state," Jason Ouimet, executive director of the group's Institute for Legislative Action, said in a statement. He said the case underscores the "need for judges who will faithfully interpret the law in defense of their rights and liberties."

The Firearms Policy Coalition said the state law prohibiting local gun ordinances is important because it keeps residents from having to navigate dozens of different firearms laws depending on what part of the state they visit.

"Pennsylvania's preemption statute serves an important purpose, to ensure that Pennsylvanians are not subjected to a patchwork of illogical and inconsistent rules and regulations pertaining to the firearms they chose to employ," Adam Kraut, the group's director of legal strategy, said.

Prince said the city should face consequences for its decision to flaunt state law.

"We look forward to Judge James issuing a decision on Allegheny County Sportsmen's League's contempt petition against the City of Pittsburgh and District Attorney Zappala filing criminal charges against Mayor Peduto and the City Council Members who enacted these illegal ordinances," he said.

Prior to the passage of the ordinances, Allegheny County DA Stephen Zappala warned the city council and mayor that they could face criminal complaints if they voted to pass measures that violate state law. However, after the ordinances passed, he refused to accept complaints filed by local residents before the measures were enforced.

Despite the possibility of legal action should the measures ever go into effect, Mayor Bill Peduto (D.) said the city would appeal the decision.

"The city and its outside legal counsel have always expected this would be a long legal fight, and will continue to fight for the right to take common sense steps to prevent future gun violence," Tim McNulty, a spokesperson for the mayor, told WTAE. "We will appeal."

Pittsburgh was defended in part by Everytown Law, an arm of the gun-control group Everytown for Gun Safety. The group also helped represent the cities of Edmonds, Wash., and Missoula, Mont., in similar cases attempting to defy state preemption laws. Those cities were also dealt legal defeats in the last two weeks.