Restrictive firearms rules in Boston and Brookline are constitutional and do not infringe on the Second Amendment's right to bear arms, the US Court of Appeals for the First Circuit said in a decision.

The implementation of the Massachusetts firearms licensing statute in Boston and neighboring Brookline "passes muster under the Second Amendment," the court said in upholding a lower court's ruling.

The case was brought by individuals who received licenses to carry firearms in public but faced restrictions. More than 40 percent of licenses are issued in Boston without restrictions, and 35 percent of licenses are restricted in Brookline.

Cities and towns with restrictions on more than half of licenses include Springfield, Lowell, New Bedford, Newton and Medford. The majority of Massachusetts communities have less restrictive licensing policies.

Under Boston's policies, licenses can be restricted to employment, hunting and target practice, or sport, while Brookline can restrict for employment, target practice, sport, transport, use in and around a home, and collecting. Licenses are processed through the police department.

In both Brookline and Boston, license applicants are required to "articulate a reason to fear injury to himself or his property that distinguishes him from the general population," according to the court.

The plaintiffs in the case, who are members of the nonprofit Commonwealth Second Amendment, Inc. (Comm2A), sought unrestricted licenses for self-defense. In pursuing the court case, the nonprofit says it's highlighting the uneven nature of cities and towns issuing licenses to carry.

One of the plaintiffs, a professional photographer in Brookline, was granted a restricted license that allowed him to carry firearms at home, during recreational activities and when he was working with expensive photography equipment.

But the First Circuit of the US Court of Appeals ruled that the right to self-defense is at its "zenith inside the home," and the right is "plainly more circumscribed" outside.

The "core right" protected by the Second Amendment is for citizens to use arms in defense of home, the court said in its decision. "Public carriage of firearms for self- defense falls outside the perimeter of this core right."

The state's firearms license statute "takes into account the heightened needs of some individuals to carry firearms for self-defense and balances those needs" against public safety demands, the court added.

"The Boston and Brookline policies fit seamlessly with these objectives," the court said.

In a statement on Twitter, Comm2A said they weren't surprised by the ruling. "Onward and Upward," the group added.

Massachusetts Attorney General Maura Healey, who has pushed for stricter gun laws, hailed the ruling in her own statement.

"The Court's decision to uphold our state's firearms licensing law will allow us in law enforcement to continue the important work of reducing gun violence and protecting public safety," she said.