WASHINGTON — The Supreme Court said on Monday that it would not decide what would have been its first decision on the scope of the Second Amendment in almost a decade, finding that New York City’s repeal of the gun control regulation under challenge had made the matter moot.

When the court agreed to hear the case, the possibility of such a ruling alarmed gun control proponents, who urged New York officials to repeal the regulation. The city did so, and state lawmakers later enacted a law that seemed to make it impossible for city officials to change their minds.

James E. Johnson, New York City’s corporation counsel, said the court’s ruling was “just right.”

“The court properly recognized that the only claims the petitioners ever brought no longer present a live case, because the challenged city rule no longer exists,” Mr. Johnson said in a statement. “The question is, in a word, moot.”

The majority opinion was unsigned and just two pages long. Justice Samuel A. Alito Jr., joined by Justice Neil M. Gorsuch and, for the most part, Justice Clarence Thomas, issued a 31-page dissent. It said that the case was not moot and that the regulation flatly violated the court’s Second Amendment precedents.