Two Los Angeles City Council committees rejected the advice of the city attorney and voted Monday to approve an ordinance that allows marijuana dispensaries to continue to sell the drug to people with a doctor’s recommendation.

The city attorney’s office has maintained for a year and a half that Los Angeles has no choice but to ban sales because state law and court decisions are clear that collectives can only cultivate marijuana. That opinion had stalled the council’s deliberations because dispensary operators insisted it would force them to close.

Four hours into a raucous hearing, frustrated council members decided to replace the provision with one that authorizes cash contributions as long as they comply with state law, which prohibits collectives from making a profit.

“When can we finally stop the merry-go-round?” said Councilman Dennis Zine, who urged his colleagues to discard the city attorney’s version. “We’re going to come back with another version and another version, and it’s going to be 2010, and then 2011 and 2015, and we’ll be dead by then and we won’t accomplish anything.”

The decision broke the major deadlock on the contentious issue. The planning and Public Safety committees sent the draft ordinance to the full council, which is likely to consider it Wednesday.

“We need something on the books now. There is no reason why we should delay,” said Councilman Ed Reyes, who has overseen the council’s effort to write an ordinance.

Don Duncan, a Los Angeles resident who is the California director of Americans for Safe Access, said he believed the decision would resolve one of the last obstacles. “It sounded like they were going to let a patient walk in and reimburse a collective for their medicine. We can live with that,” he said.

The council’s action came after a judge ruled last month that the city’s 2007 moratorium on new dispensaries was illegally extended, which essentially left the city with no rules that it could rely on to shut down the hundreds of stores that have opened in the last two years.

Some council members responded favorably to the city attorney’s suggestion to consider capping the number of dispensaries. Councilman Jose Huizar proposed a cap of 70, allowing two in each of the 35 community plan areas.

“Hopefully, that will allow us to control for the over-concentration,” he said.

Almost 400 people crowded into the main council chamber and about 70 spoke, most testifying passionately about the medical value of marijuana and the role dispensaries play. If the council members decide to ban sales, said Degé Coutee, who runs the Patient Advocacy Network, “You will create a black market overnight. You will turn good citizens into criminals overnight. And you will get the city involved in costly litigation for years to come.”

About a half-dozen neighborhood activists spoke. Their complaints about vandalism, noise, loitering and dispensary operators with criminal backgrounds drew thundering boos and persistent catcalls from medical marijuana supporters.

“This has become a public safety nightmare,” said Michael Larsen, the public safety director for the Eagle Rock Neighborhood Council. James O’Sullivan, the president of the Miracle Mile Residential Assn., advised: “Do the right thing. Protect your community.”

A vote for a sales ban would take Los Angeles into uncharted legal territory. Two organizations, Americans for Safe Access and the Union of Medical Marijuana Patients, have threatened to sue the city if the council adopts the provision.

Throughout the hearing, William Carter, the chief deputy city attorney, cited state law and court decisions and insisted they do not allow collectives to sell marijuana.

Several council members pointed out that West Hollywood has an ordinance that allows sales.

“There are other cities throughout the state that may not be complying with state law as we see it,” Carter said.

Reyes, who expressed exasperation with the city attorney’s office, said, “I think they are very, very narrow in that they’re taking their prosecutorial perspective.”

Zine urged the council to interpret state law in a way that would not disrupt how dispensaries now operate.

“Why don’t we push the envelope to the edge and see what we can do?” he said.

After the vote, David Berger, a special assistant to City Atty. Carmen Trutanich, said the council had the right to decide whether to accept the office’s legal advice. “Our duty is to advise them on what the law allows for, not to go on a whim,” he said. “They decided to go a different way.”

john.hoeffel@latimes.com