“It’s unthinkable that people could say that those weapons of war are protected by the Second Amendment,” Maryland Attorney General Brian E. Frosh said Tuesday. (Jonathan Newton/The Washington Post)

A federal appeals court on Tuesday upheld Maryland’s ban on semiautomatic guns with certain military-style features that the state passed after the 2012 mass shooting at a Newtown, Conn., elementary school.

The 10-to-4 ruling by the U.S. Court of Appeals for the 4th Circuit vacates an earlier panel decision that cast doubt on the constitutionality of the ban that is similar to laws in seven states, including California, Connecticut and New Jersey.

The ruling from the Richmond-based court goes further than other appellate courts that have reviewed similar laws in stating clearly that “assault weapons and large-capacity magazines are not protected by the Second Amendment.” The majority opinion, written by Judge Robert B. King, refers to the banned firearms as “weapons of war” that the court says are most useful in the military.

In a strongly worded dissent, Judge William B. Traxler Jr. said his colleagues have “gone to greater lengths than any other court to eviscerate the constitutionally guaranteed right to keep and bear arms.”

The question for the court was how far the Maryland legislature could go to limit individual rights to gun ownership and what standard a District Court judge in Baltimore should have used to assess the law.

Last February, a three-judge panel of the 4th Circuit found that the Baltimore judge should have used a more stringent test: The bar should be higher for the state, the panel said, when the government passes a law that affects a right protected by the Constitution.

The majority disagreed in its opinion Tuesday siding with Maryland Attorney General Brian E. Frosh who said the Second Amendment does not prevent legislators from passing measures designed to protect the public from gun violence.

“It’s unthinkable that people could say that those weapons of war are protected by the Second Amendment,” Frosh said Tuesday. “Especially when you look at the carnage at Newtown and elsewhere around the country.”

Maryland’s law does not ban all long guns, rifles or semiautomatic rifles. Gun restrictions enjoy wide support in the Democratic-leaning state, a factor that helped legislators pass some of the nation’s strictest gun-control laws in 2013.

Opponents of Maryland’s law — including the Maryland State Rifle and Pistol Association and the Maryland Licensed Firearms Dealers Association — told the court that the prohibited firearms are not military weapons and that many owners have bought the guns for lawful purposes such as self-defense, target practice and hunting.

The challenge was one of series of cases that followed the Supreme Court’s 2008 ruling that for the first time declared that the Second Amendment guarantees an individual right to gun ownership rather than one related to military service.

The Supreme Court has not gone further to define the parameters of the right, such as weighing in on the legality of restrictions on certain weapons. The high court has repeatedly declined to review bans on firearms that New York, Connecticut and other jurisdictions have classified as “assault weapons.”

Like Maryland, Connecticut’s ban was expanded after a gunman used a military-style semiautomatic weapon to kill 20 students and six teachers at Sandy Hook Elementary School.

The 81-page opinion issued Tuesday opens with a detailed description of that day, including the number of rounds of ammunition fired, and goes on to describe mass shootings involving similar military-style firearms in a long list of other U.S. cities.

“We have no power to extend Second Amendment protection to the weapons of war that the Heller decision explicitly excluded from such coverage,” King wrote in the 4th Circuit opinion, referring to the Supreme Court case known as District of Columbia v. Heller.

The court also found that Maryland lawmakers were justified in passing the ban in the interest of public safety because magazines holding more than 10 rounds of ammunition “enable shooters to inflict mass casualties while depriving victims and law enforcement officers of opportunities to escape or overwhelm the shooters while they reload their weapons.”

In a separate concurring opinion, Judge J. Harvie Wilkinson III said state governments — not the courts — have long been responsible for the safety of residents. The Supreme Court in Heller, Wilkinson said, did not prevent elected officials from regulating “assault weapons.”

“Disenfranchising the American people on this life and death subject would be the gravest and most serious of steps,” Wilkinson wrote. “It is their community, not ours. It is their safety not ours. It is their lives, not ours.”

The four dissenting judges said the banned firearms are not “dangerous or unusual” and are used by millions of law-abiding Americans in part because the military-style components increase accuracy and improve ergonomics.

“As long as the weapon chosen is one commonly possessed by the American people for lawful purposes — and the rifles at issue here most certainly are,” wrote Judge Traxler, who was joined by Judges Paul V. Niemeyer, Dennis W. Shedd and G. Steven Agee. “The state has very little say about whether its citizens should keep it in their homes for protection.”