Justice Alito, who was joined by Chief Justice John G. Roberts Jr. and Justices Antonin Scalia, Anthony M. Kennedy and, in large part, Clarence Thomas, acknowledged that the decision might “lead to extensive and costly litigation,” but said that was the price of protecting constitutional freedoms.

The majority offered the lower courts little guidance about how much protection the Second Amendment affords. In a part of his opinion that Justice Thomas declined to join, Justice Alito reiterated the caveats in the Heller decision, saying the court did not mean to cast doubt on laws prohibiting possession of guns by felons and people who suffer from mental illness, laws forbidding carrying guns in sensitive places like schools and government buildings, or laws regulating the commercial sale of firearms.

The important point was a broad one, Justice Alito wrote: that the Second Amendment, like other provisions of the Bill of Rights, must be applied to the states under the 14th Amendment.

Justices John Paul Stevens, Ruth Bader Ginsburg, Stephen G. Breyer and Sonia Sotomayor dissented. They said the Heller decision remained incorrect and added that they would not have extended its protections to state and local laws even had it been correctly decided.

“Although the court’s decision in this case might be seen as a mere adjunct to Heller,” Justice Stevens wrote, “the consequences could prove far more destructive — quite literally — to our nation’s communities and to our constitutional structure.”

Though the majority agreed on the outcome, its members differed about how to get there.

The Second Amendment, like the rest of the Bill of Rights, originally restricted the power of only the federal government. The Supreme Court later ruled that most of the protections of the Bill of Rights applied to the states under the due process clause of the 14th Amendment, one of the post-Civil War amendments.