The police department had to apply for a federal firearms license to act as the gun broker. A department spokesman said the license was granted last week.

Mayor Muriel E. Bowser (D) said officials will continue to seek a private dealer to replace Charles Sykes, the firearm licensee who had been handling such transactions, but they didn’t want to leave people unable to obtain guns in the interim. She said once a replacement is found, police will give up that part of the job.

Several court rulings dating to 2008 forced the District to loosen its restrictive gun laws. A landmark Supreme Court decision in 2008 declared an individual right to gun ownership, and an appeals court ruling in 2017 struck down a city law requiring residents to show a “good reason” to carry a firearm outside the home.

District officials said they could not immediately find a replacement for Sykes and took the unusual step of putting the police in charge of firearms transactions to avoid litigation or other chal­lenges. Bowser said she didn’t want “to run into any constitutional issues or open ourselves up to meddling in our gun laws to outside groups.”

Jonathan Lowy, director of the legal action project at the Brady Center to Prevent Gun Violence, said he had not heard of another law enforcement agency taking over as a de facto gun dealer to facilitate private firearms transactions.

“It does sound like the District is going the extra mile to protect the Second Amendment rights of D.C. residents,” Lowy said. He also called the move prudent, saying it could stave off a potential legal challenge by people otherwise unable to obtain firearms.

Lawrence Keane, senior vice president and general counsel of the National Shooting Sports Foundation, said police handling the transactions is acceptable in the interim, but he does not believe that law enforcement should be involved with firearm pur­chases.

Keane said he is concerned about the police collecting information on forms that buyers must fill out. “I think gun owners would be very concerned about purchasing firearms from the police,” he said.

In the new role, D.C. police will assume the same responsibilities as Sykes, who did not sell firearms in the same way a traditional shopkeeper does.

Federal law requires that handgun buyers purchase their weapons in the states where they live. There are no gun stores in the District.

Under a unique workaround, people in the District who passed background checks and qualified would pick out guns in stores in Maryland, Virginia or elsewhere, and arrange for them to be shipped to Sykes’s office. He would then handle the paperwork, completing the formal purchase in the District.

Sykes charged $125 for this service. A spokeswoman for the District’s deputy mayor for public safety said the city would continue to charge the fee.