SAN FRANCISCO — Unless the Legislature intervenes, California will be dotted with a few cities that allow medical marijuana dispensaries but otherwise be ruled by large areas that outlaw the pot businesses.

That appears to be the medical marijuana landscape statewide under a ruling Monday by the California Supreme Court, which settled the latest legal battle over the state’s 17-year-old experiment with medical pot by upholding local governments’ right to ban dispensaries. The unanimous decision leaves intact a growing movement to forbid pot businesses despite a 1996 state law permitting medical use of marijuana.

In a 7-0 decision, the state’s high court rejected medical marijuana advocates who maintain local governments cannot bar activity that is legal. The ruling could be used to bolster cities that want stricter rules on pot dispensaries, particularly in San Jose, which during the court showdown put on hold its drive to reduce the number of pot clubs in the city.

“While some counties and cities might consider themselves well suited to accommodating medical marijuana dispensaries, conditions in other communities might lead to the reasonable decision that such facilities within their borders … would present unacceptable local risks and burdens,” Justice Marvin Baxter wrote for the court.

At least 180 cities across the state and Bay Area have bans, from Hollister to Petaluma to Moraga. But the region’s largest cities, San Jose, San Francisco and Oakland, have permitted the dispensaries, taxing the revenues while communities in between increasingly become dispensary-free zones.

In the short term, the ruling is expected to preserve the status quo because cities have already moved ahead with bans despite the legal uncertainty. Oakland City Councilwoman Rebecca Kaplan said she hopes other cities will follow Oakland’s model and regulate the dispensaries rather than ban them.

San Jose Mayor Chuck Reed and San Jose City Attorney Rick Doyle, meanwhile, said the decision allows San Jose to regulate dispensaries, setting up more debate over how to deal with a proliferation of the outlets. Reed said he’ll pursue a “balanced approach to regulating medicinal marijuana.”

Dispensary owners, however, expressed dismay at the ruling, saying it creates a problem for legitimate patients in communities without dispensaries nearby.

“Those patients are going to be forced to obtain their (medical pot) from gangs and cartel-related sources instead of regulated facilities,” said Steve DeAngelo, executive director of the Harborside Health Center, which has dispensaries in San Jose and Oakland that federal prosecutors are trying to shut down.

Many local governments banned the dispensaries due to worries about lax control over the distribution of a drug that remains illegal under federal law. The Supreme Court found that although California’s Proposition 215 permitted legal possession of medical pot, it did not address local regulation.

As a result, Baxter wrote, local governments can use nuisance laws and other regulations to ban activities and land uses such as the dispensaries.

The Supreme Court decision came in a challenge to Riverside’s dispensary ban. Riverside, backed by groups such as the League of California Cities, argued that local governments have strong rights to regulate land use, particularly an unusual one such as a medical pot dispensary.

“This ruling assures local governments throughout California that they have the constitutional right to impose bans,” said Jeffrey Dunn, Riverside’s attorney.

The Riverside dispensary owner said he will close.

“The court chose chaos over regulation,” added David Nick, the dispensary’s lawyer. “I expect many collectives around the state will resist local ordinances and continue to litigate.”

Medical marijuana advocates say the bans undermine the intent of the state law, which they argue was meant to give patients across the state uniform access to medical cannabis for illnesses such as cancer or AIDS. The bans, they say, force many patients to drive long distances to obtain the drug — for example, most Peninsula patients must travel either to San Jose or San Francisco.

Americans for Safe Access, a leading marijuana advocacy group, said in a statement Monday that groups will now push legislation mandating uniform dispensary rules statewide. The Supreme Court indicated that the Legislature could act if it decides cities should not be able to ban the dispensaries.

The Supreme Court’s decision was not unexpected. Legal experts have predicted the justices would be reluctant to strip cities of the right to enact the bans.

“This ruling makes clear that current state law does not grant a right of convenient access to medical marijuana,” said Julie Nice, a University of San Francisco law professor.

Staff writers Matthew Artz and Tracy Seipel contributed to this story. Howard Mintz covers legal affairs. Contact him at 408-286-0236 or follow him at Twitter.com/hmintz