HARRISBURG - The Pennsylvania Supreme Court on Monday declined to reinstate a law that gave groups like the National Rifle Association the right to challenge local gun-control rules in court.

Commonwealth Court overturned the law last year on the ground that the legislative process used to make it had violated the state constitution. The gun provision had been added to a bill that addressed the theft of metals.

The Supreme Court agreed "that the legislature violated the single-subject rule in an effort to pass an unpopular and irrational bill without being noticed," said Sen. Daylin Leach (D., Montgomery), who led the lawsuit challenging the law.

House Speaker Mike Turzai and Senate President Pro Tem Joe Scarnati had appealed the Commonwealth Court ruling. Drew Crompton, the Senate GOP general counsel, said he assumed the Senate would try again to pass such a proposal, adding that some towns were going overboard in regulating gun sales.

"Some municipalities are simply going far afield of the powers they are given pertaining to gun ownership and there should be penalties for local regulation that is not in accord with current state law," Crompton said in an email.

The mayors of Philadelphia and Pittsburgh, which have faced lawsuits challenging gun restrictions, praised the ruling.

"This is a great victory for proper legislative procedure and for the ability of local governments to adopt commonsense gun regulations without fear of financially crippling litigation," Mayor Kenney said in a statement.

"This ruling confirms what Mayor Peduto and others have been saying for years - that this bill was clearly illegal, and a cynical attempt to score points with the gun lobby at the expense of neighborhoods living in fear from illegal gun violence," said Timothy McNulty, spokesman for Pittsburgh Mayor Bill Peduto, in an email.