The shops must close before a long-debated city ordinance takes effect June 7, or face criminal and civil penalties. About 130 dispensaries that registered with the city could be allowed to stay open.

Los Angeles city prosecutors began notifying 439 medical marijuana dispensaries Tuesday that they must shut down by June 7, when the city's ordinance to regulate the stores takes effect. It's the first step in what could be a lengthy and expensive legal battle to regain control over pot sales.

The letters, which were sent to both dispensary operators and property owners, warn that violations of the city's laws are a misdemeanor and could lead to six months in jail and a $1,000 fine. Collectives that stay open after the deadline could also face civil penalties of $2,500 a day.

"We're hopeful that the fact that we've given them more than 30 days to comply that a significant number of them will cease operating," said Asha Greenberg, the assistant city attorney who has handled most of the efforts to close dispensaries.

Los Angeles became the epicenter of the state's dispensary boom last year, following the Obama administration's announcement that it would not prosecute medical marijuana stores that adhered to state law. Although the city had a moratorium on new dispensaries, it failed to enforce the ban and hundreds opened with no oversight, triggering complaints from neighborhood activists.

The letters were welcomed by city officials and activists as a sign that the contentious issue, which was first considered by the City Council five years ago, is nearing a resolution.

"We've arrived. It's like being on a journey and saying, 'Are we there yet? Are we there yet?' " said Councilman Ed Reyes, who oversaw the laborious process that led to an ordinance after two years of debate. "It feels good that we have finally reached this threshold."

Michael Larsen, the incoming president of the Eagle Rock Neighborhood Council, was the most tenacious spokesman for residents worried about unregulated dispensaries. "There's actually something happening based on an ordinance that we worked very hard to get into place. On that level, I am relieved," he said. "The truth about the actual enforcement, that will just be a big question mark."

Under the new ordinance, only dispensaries that registered with the city after the council adopted the moratorium in 2007 will be allowed to operate. City officials estimate that more than 130 of the original 186 registered dispensaries are still in business.

The Los Angeles Police Department cased the city to try to find every dispensary. Estimates from city officials and medical marijuana activists had ranged as high as 1,000. But Capt. Kevin McCarthy, who heads the LAPD's Gangs and Narcotics Division, said, "We came up with less than 600, which is good."

Greenberg said the city attorney's office will send out more letters if residents point out additional dispensaries. "We're making our best efforts, and we're using information from really our eyes and ears out there, which is the community," she said.

The city's enforcement efforts, however, could be stymied by court cases.

Two related lawsuits filed by dispensaries challenge the City Council's decision to close stores that did not register under the moratorium, which a local judge ruled was illegally extended. "We're looking for the court to just acknowledge that our clients are unlawfully discriminated against," said David Welch, a lawyer who represents 36 dispensaries in the lawsuit.

Eric Shevin, another lawyer with experience in marijuana issues, is preparing to sue on behalf of patients. "We are putting together a very comprehensive lawsuit to strike down L.A.'s ordinance," he said, arguing that the law imposes unreasonable restrictions on patient access to medicine. "There is really nothing that allows medical marijuana patients to be treated differently than, say, Vicodin patients."

Los Angeles has tried twice to persuade dispensaries to shut down, with mixed results. City prosecutors sent letters last year ordering 53 stores to close after the City Council denied their applications to operate despite the ban, and 28 did so. Earlier this year, letters were sent to the landlords of 21 dispensaries targeted by LAPD undercover operations, and six stores closed.

McCarthy said he hopes most dispensaries will close voluntarily. He believes many operators are conscientious, but notes that others are not. "I don't know what percentage of them are knuckleheads, and because the money is pretty good, we're not going to get 100%" compliance, he said.

Noting that medical marijuana is not the narcotics division's highest priority, he said it could take some time to determine which dispensaries remained open beyond the deadline. He said his officers would focus on the biggest nuisances: "Obviously, the ones that the community is screaming about are the ones we are going to go to first."