A federal judge in Maryland has ruled that state residents no longer must show they have a good reason to carry a handgun outside their home, declaring a key provision of the state’s gun-control laws unconstitutional.

Gun rights advocates said the opinion — in a relatively liberal state with some of the country’s tightest gun restrictions — would help as they challenge similar laws in about a half-dozen states. Maryland officials said Monday that they are seeking a stay and will appeal the decision.

U.S. District Judge Benson Everett Legg focused on one portion of Maryland law that requires residents to show they have a “good and substantial reason” to carry a gun, such as a “precaution against apprehended danger.” Legg found that the requirement, kicking in alongside background checks, was too broad and said it violates the Second Amendment.

“The Court finds that the right to bear arms is not limited to the home,” Legg wrote in a 23-page ruling signed Friday.

The judge added that the requirement for issuing a handgun permit amounts to a “rationing system” to limit the number of guns carried outside the home. “The law impermissibly infringes the right to keep and bear arms, guaranteed by the Second Amendment,” he wrote.

The case centered on a Navy veteran, Raymond Woollard, who was denied a handgun permit in 2009.

In 2002, Woollard’s son-in-law broke into Woollard’s rural Baltimore County home, high on drugs and looking for car keys so he could drive to Baltimore and get more drugs, Legg wrote. Woollard pointed a shotgun at his son-in-law, who managed to wrestle it away before being subdued by Woollard’s son, who also pointed a gun at the intruder.

Woollard applied for and was granted a permit to carry a handgun, according to the ruling. He was allowed to renew his permit in 2006, shortly after his son-in-law was released from prison, the judge wrote. But three years later, his renewal was denied, prompting him to appeal to the state’s Handgun Permit Review Board.

The board ruled that Woollard had “not demonstrated a good and substantial reason to wear, carry or transport a handgun as a reasonable precaution against apprehended danger in the state of Maryland.”

In the summer of 2010, Woollard sued.

Under state law, applicants for a carry permit must show, among other things, that they are not addicted to drugs or alcohol, don’t have a history of violence and haven’t been convicted of a crime and sentenced to more than a year behind bars. Those requirements still stand.

Legg’s ruling only upended the “good and substantial reason” requirement. In his ruling, he said Maryland State Police have issued permits to people in professions that may carry a risk, such as armored-car drivers, security guards, police officers and prosecutors. Permits also go to those who can show they need “personal protection.”

The judge wrote that the requirement doesn’t ensure that guns are kept away from people “most likely to misuse them,” criminals or the mentally ill, for instance. Nor, he wrote, does it ban guns in churches, government buildings or places where the “possibility of mayhem is most acute.”

“It’s definitely a great boost for the right to bear arms,” said Alan Gura, a lawyer in the case who earlier helped overturn gun-control measures in the District. “People around the country are a little more secure in their freedoms today.”

But others said that an important safeguard in Maryland — the ability to judge whether someone really needs to carry a gun in public — has been stripped away.

“This is a potentially very dangerous decision,” said Jonathan Lowy, director of the Legal Action Project at the Brady Center to Prevent Gun Violence, which supported the state in the lawsuit. “People of Maryland have right to decide who can carry loaded guns in the public places that we all enjoy.”

“I don’t think this is a decision that will enhance public safety,” said Daniel Webster, co-director of the Johns Hopkins Center for Gun Policy and Research. “It will more likely harm public safety.”

The fight over gun rights in Maryland also reaches into the state legislature and produces a perennially heated debate in Annapolis, with Republicans blasting Democrats for imposing gun laws on the state’s entire population that are tailored for the Baltimore and Washington areas.

Republican lawmakers have four bills pending in the House of Delegates to repeal the “good and substantial reason” requirement. Similar bills have failed repeatedly in recent years. There are now about 12,000 active handgun permits in Maryland, according to the state police.

Officials have denied an average of 214 applicants annually since 2009 on the basis of a finding that the person did not have a substantial reason to wear, carry or transport a gun, according to the state Department of Legislative Services.

During debate on the Republican-sponsored bills this year, state police warned that undoing the requirement would result in an initial wave of 15,000 applicants for handguns in the budget year beginning in July and that an additional 10,000 people would apply, on average, every year thereafter.

But the state’s nonpartisan budget analyst’s office took issue with those estimates. It said the state police had failed to provide a rationale for such a large projected increase. The analyst’s office, nonetheless, estimated that the number of gun applications statewide would double, to about 3,600 annually.

During a Feb. 21 hearing in the House Judiciary Committee, dozens of gun rights advocates crowded the committee room to testify about the difficulty of obtaining a permit to carry a gun in Maryland.

Del. Michael D. Smigiel Sr. (R-Cecil), the lead sponsor of one of the bills, argued that the ability to carry a gun is an “unalienable right that comes from God” and grilled Maryland State Police Lt. Jerry Beason about the necessity of the “good and substantial reason” clause. Beason conceded that the phrase is “impossible” to define.

“Shame on the state of Maryland,” Smigiel said.

Staff writers Fredrick Kunkle and Greg Masters and staff researcher Jennifer Jenkins contributed to this report.