D.C. Mayor Vincent C. Gray, left, and D.C. Council Chairman Philip H. Mendelson, right, prepare to testify before a Senate committee this month. Mendelson played a leading role in developing the city’s new gun-carry proposal. (J. Scott Applewhite/AP)

The D.C. Council voted Tuesday to grant residents and visitors the ability to carry concealed firearms in public, but the bill would establish a regulatory structure that could make it difficult for gun owners to secure a permit.

The legislation passed unanimously, although several of the council’s 13 members said they were voting for the measure reluctantly after a federal judge struck down the city’s long-standing ban on carrying weapons.

Council member Mary M. Cheh (D-Ward 3) said before the vote that she was “deeply disappointed” by the demise of the city’s decades-old ban on carrying guns and said the court ruling, in her view, did “grievous harm to public safety” in the nation’s capital.

But Cheh joined her colleagues in voting for the bill, knowing that the July court order would otherwise invalidate much of the city’s gun-control statute and that prosecutors have already ceased pursuing unlicensed-carrying charges.

“We really don’t want to move forward with allowing more guns in the District of Columbia, but we all know we have to be compliant with what the courts say,” said Muriel Bowser (Ward 4), the Democratic nominee for mayor.

Council member Mary M. Cheh (D-Ward 3) is seen in this file photo. (Sarah L. Voisin/The Washington Post)

Before gun owners can apply for permits, Mayor Vincent C. Gray (D) has to sign the bill, and the D.C. police department has to issue regulations setting up a licensing framework, a process that could take several weeks.

Even then, very few applicants might end up qualifying for permits. “I’d be surprised if a year from now, it was more than a couple hundred,” said the council chairman, Phil Mendelson (D), who drafted the bill with mayoral and police officials.

Tuesday’s vote was another example of the city’s liberal politics clashing with the federal judiciary’s increasingly conservative interpretations of the Second Amendment. In 2008, the Supreme Court struck down the city’s three-decade-old handgun ban and set the stage for the end of the public-carry prohibition.

Mendelson said the new carry legislation is among the strictest in the nation, with the city preparing to join the likes of Maryland, New Jersey and New York in establishing a highly restrictive regime that requires applicants to state good reason to carry a weapon. But he said a flat ban was no longer constitutionally feasible.

“If it looks like we’re being cranks . . . and we don’t want anyone to get a license, we’re in trouble in court,” he said. “I do think this will survive a [legal] challenge.”

Although city officials have not decided whether to appeal the judge’s ruling, some have said that they would rather do so with the emergency law in place — allowing the carrying of weapons, but with restrictions — than with only the outright ban that the judge struck down.

But Cheh said she was afraid that passing the bill would prevent the city from fighting to keep the flat prohibition in place. Mendelson disputed that view. “It doesn’t go where the gun advocates want to go,” he said of the emergency bill. “I am certain they will not dismiss this case as moot.”

Alan Gura, the attorney for D.C. residents and workers who challenged the ban, said Monday that what becomes of the city’s gun laws will, indeed, continue to be an issue in the federal courts. Gura said the bill that passed Tuesday “plainly fails to comply with the court’s ruling” striking down the carry ban.

“The court instructed the city to treat the carrying of handguns as a right rooted in the constitutional interest in self-defense,” he said. “It’s not much progress to move from a system where ­licenses are not available to a system where licenses are only available if the city feels like issuing them. It’s something of a joke.”

Gura said he is prepared to take the matter before U.S. District Judge Frederick J. Scullin Jr., who struck down the carry ban in July and has scheduled an Oct. 17 hearing on the city’s request that he reconsider his decision.

“They have to explain why this is different than what currently exists,” Gura said. “I don’t believe they can do that.”

The bill would allow city residents who own properly registered handguns, as well as nonresidents with a state carry license, to apply for a permit to bear a concealed weapon in the District.

But applicants would need to show “good reason to fear injury to his or her person or property” or “any other proper reason for carrying a pistol,” and they would have to pass rigorous background checks and training requirements. The final decision on whether to issue a license would be the police chief’s, with appeals handled by a five-member review board.

Federal judges have upheld similar “may-issue” discretionary laws in Maryland and New Jersey, but an appeals court recently struck down California’s may-issue concealed-carry law.

Under the D.C. legislation, firearms could not be carried in schools, hospitals, government buildings, public transportation vehicles, establishments serving alcoholic beverages, stadiums or arenas. Nor could they be carried within 1,000 feet of a dignitary under police protection.

The District’s gun law stands to be refined further, whether by the courts or by the council. Once Gray signs the emergency bill, it will be effective for 90 days. Drafting permanent legislation is a longer process, involving public hearings, multiple council votes and a period of congressional review.

The council debated a amendment to the emergency bill — from David Grosso (I-At Large) — that would require that the names of those licensed to carry arms be disclosed in a public database. But Grosso withdrew the proposal at Mendelson’s request, saying he would seek to have the provision included in a permanent bill.