The regulation of medical marijuana in Los Angeles is a mess and has been ever since Proposition 215 was approved by California voters in November 1996.

Repeated state and city efforts to bring the chaotic situation under control have had little effect. A move by the City Council in 2007 to register medical marijuana dispensaries, for instance, led instead to an unexpected proliferation. An attempt to limit them in 2010 drew 66 lawsuits and a court-ordered injunction. An ordinance to ban them outright in 2012 was quickly repealed after marijuana businesses gathered enough signatures for a referendum to overturn the measure. Court decisions designed to clarify the murky laws have instead contradicted one another.

Today, there are an estimated 850 dispensaries — or maybe it's 1,000 or 1,600 (no one seems sure) — operating in Los Angeles despite the city's position that they're illegal. Everyone knows that medical marijuana can be easily obtained by recreational users who aren't truly sick. The "medicine" is not monitored by the government for potential health or safety problems; the dispensaries, by many accounts, are not nonprofit "collectives," as state law requires (although it's not really clear what a nonprofit collective is or isn't). Residents in some neighborhoods complain that they are being overrun by dispensaries, and that many pot shops serve as hubs for crime.

A mess, like we said. And on May 21, Angelenos will have the opportunity to muck it up even further, if they're not careful. On the ballot will be not one or two but three competing marijuana initiatives: Measures D, E and F.

It would be easy enough to urge a no vote on all three, and to call on the city to impose a full-scale ban instead. After all, The Times opposed Proposition 215 from the outset, partly because it was sloppily written and partly because it set up an inevitable conflict with the federal government, which continues to classify marijuana as illegal and dangerous.

But voting no solves nothing. The people of Los Angeles, like the people of California, overwhelmingly support making medical marijuana available to cancer patients, glaucoma sufferers and others. A ban would be unlikely to pass, and besides, denying marijuana to truly sick patients who can benefit from it would be a step backward. Given that, and given that the status quo is entirely unacceptable, the city's best hope is to try to carry out the will of the voters with minimal confusion and maximum control to ensure that medical marijuana remains accessible to those who need it.

Measure D will come the closest to accomplishing that goal, or at least will put us on the right road.

Most important, it would impose limits on the number of marijuana businesses in the city, allowing about 135 dispensaries to remain open — those that were operating and registered under city laws in 2007 and that sought to re-register in 2011. Limits are essential. Even people who support easy access to medical cannabis can see that there need to be rules and oversight, as with bars and liquor stores. But resources are limited, and the city can't police an infinite number of establishments.

Measure D is backed by both mayoral candidates and the current city attorney and his challenger. It applies to any organization of four or more people who cultivate, process, distribute or give away medical marijuana. It hikes the gross receipts tax on their operations — to $60 per $1,000 of gross receipts — and establishes the distances they must keep from schools, parks, one another and residential neighborhoods. It sets hours — they must be closed between 8 p.m. and 10 a.m. — prohibits the consumption of marijuana on the premises and requires background checks on managers, among other provisions.

It is far from perfect. For one thing, it is somewhat arbitrary. Why should a handful of dispensaries that got in under the wire in 2007 be the ones that now get to stay open? There's no reason to think those particular establishments are more responsible than any other. For another, if it is passed, the city will be required to close hundreds of existing dispensaries, which could prove difficult, legally and practically. Here's another thing: Measure D doesn't create a process for a new dispensary to open when one of the 135 closes; that seems like an unfortunate oversight. And it would be far better if the measure could be amended or repealed by the City Council without requiring an additional vote of the people. But it cannot.

Still, Measure D is the best of the bunch.

Measure F, by contrast, sets no limits. It includes some strong rules and protections — in some cases stronger than those in D. But the city simply can't sustain an unlimited number of dispensaries. Supporters of F say there would be de facto limits as a result of the requirements about how close dispensaries could be to schools, parks and one another, and that the final number would be in the hundreds. But what guarantee is there? Certainly nothing in the law.

As for Measure E — ignore it. That measure became moot after its supporters agreed to throw their support to Measure D.

No matter what you think of medical marijuana, it's hard to deny that implementation of Proposition 215 has been unsuccessful. The Legislature and the state attorney general's office were late to offer much-needed guidance. The federal government sent mixed messages about what it would or would not tolerate. The city of Los Angeles has flailed around, trying and failing to devise a workable set of rules.

Even if Measure D passes, there will still be no way to ensure that medical marijuana goes only to the sick people who are entitled to it, or that the product being sold is safe and untainted. Moreover, there will still be no resolution to the ongoing conflict between state and federal law. Perhaps one day the U.S. government will decide that marijuana should no longer be a Schedule I controlled substance, which means it has no medical use and is as dangerous as heroin. If that happens, perhaps the Food and Drug Administration will regulate it, doctors across the country will be able to prescribe it for patients they believe need it, and pharmacies will be able to provide it, just as they do with other medicines.