The District’s top lawyer on Monday sought to temporarily halt a federal court ruling allowing thousands of city residents with registered handguns — as well as legal gun owners from other states — to carry firearms on the streets of the nation’s capital.

The ruling, which upended the city’s decades-old restrictions on carrying handguns in public, created confusion and concern as officials grappled with its implications. The law was declared unconstitutional in an opinion released over the weekend, leaving police scrambling to give clear direction to officers.

D.C. Police Chief Cathy L. Lanier told her officers Monday that they could no longer stop someone simply for carrying a gun in public; they would need suspicion that a crime had been committed. For visitors who carry guns into the city, police will need to determine whether they are following the laws of their home state.

“We understand that the immediate implementation of this ruling creates safety concerns for our members and our community,” Lanier wrote in a memo to police officers Monday. She instructed them to “continue to serve the best interest of public safety while respecting individual rights.”

Police urged officers to contact a department lawyer, on call around the clock, with questions.

D.C. officials have argued that the gun law — among the strictest in the nation — has been a pillar of their public safety strategy in a city that has historically been beset by gun violence. Mayor Vincent C. Gray (D) said Monday that he was “very troubled” by the decision. He appealed to people who live elsewhere to refrain from bringing guns into the city.

The decision, which is likely to be appealed, came five years after a lawsuit challenged the District’s outright prohibition on carrying handguns. The case is among a series of legal efforts taking on gun restrictions nationwide. It followed the 2008 landmark Supreme Court decision that used a D.C. case to declare that the Second Amendment guarantees a person’s right to own a firearm for self-defense.

U.S. District Judge Frederick J. Scullin Jr., a senior judge who normally sits in Upstate New York, struck down the city’s law because there is no process for issuing carry licenses to registered gun owners. Citing several recent court opinions, the judge found that “there is no longer any basis on which this court can conclude that the District of Columbia’s total ban on the public carrying of ready-to-use handguns outside the home is constitutional.”

He suggested city officials could create a new licensing system “consistent with constitutional standards enabling people to exercise their Second Amendment right to bear arms.”

On Monday, officials asked the judge to stop the order from taking effect for at least six months “in the interest of public safety and clarity.” They said it would allow time to file an appeal or for the D.C. Council to rewrite the law. It was not clear when Scullin would rule on the city’s motion.

Council Chairman Phil Mendelson (D) said that the panel is on summer break until late September but that it’s possible lawmakers could return for an emergency session to address the issue. “If prosecutors need legislative action, then, of course we’ll consider that,” he said.

Even with the ruling, officials said, guns remain prohibited in some areas.

Guns are not allowed on the Capitol grounds or on District government property, including schools, parks, recreation centers and office buildings. At the John A. Wilson Building, the District’s city hall, security guards on Monday continued to screen visitors with X-ray machines and metal detectors.

Private property owners, according to city law, may still ban guns from their property. In addition, it remains illegal to carry long guns or shotguns in the District, according to Lanier.

Still, as long as the ruling is in effect, it fundamentally changes the way police officers do their jobs. There have been about 3,100 handguns registered in the District since 2008, police officials said.

Delroy Burton, chairman of the D.C. police union, said it would mean a massive change in tactics for officers on city streets, who are accustomed to being able to stop someone who they suspect is carrying a gun.

The attorney general’s office said Monday that defense lawyers are already demanding that prosecutors drop charges against people found carrying guns outside the home.

“Given the complexity of the issue, it will require a significant amount of retraining because the mind-set of officers has to change for how we have to deal with that,” Burton said. “Otherwise, we’re going to expose the department, our members and the city to significant civil liability.”

Gun rights activists praised the ruling, saying there was no evidence that the restrictions had made D.C. streets safer.

“Every law-abiding person should be able to exercise their fundamental right to self-defense, which as the court in this case correctly noted, is not confined to the home,” said Chris W. Cox, chief lobbyist for the National Rifle Association.

Activists fighting gun violence expressed disappointment at the judge’s decision but urged city officials to pass strong laws for the public carrying of weapons.

“Whether or not the District decides to appeal this misguided decision, it would be a law enforcement nightmare if virtually anyone is allowed to carry loaded guns on the streets of the nation’s capital, where so many high­profile targets, tourists, foreign dignitaries and government officials could be placed at risk,” said Jonathan Lowy, director of the legal action project at the Brady Center to Prevent Gun Violence.

Mike DeBonis, Peter Hermann and Julie Zauzmer contributed to this report.

Get updates on your area delivered via e-mail