LOS ANGELES — California has entered a potentially landmark legal fight against some of its own cities over one of the most basic questions in the nation's largest legal marijuana market: Where can you buy it?

Beverly Hills and 24 other local governments sued California regulators Friday to overturn a rule allowing home deliveries statewide, even into communities that banned commercial pot sales. Ultimately at issue is who is in charge: the state bureaucracy that oversees the market or local governments where pot is grown and sold.

When California adopted the delivery rule in January, the League of California Cities and police chiefs complained that unrestricted home deliveries would create an unchecked market of largely hidden pot transactions, while undercutting local control guaranteed in a 2016 law broadly legalizing marijuana sales.

Santa Cruz County Board of Supervisors Chairman Ryan Coonerty said in a statement that the state rule damages local marijuana businesses and "betrays the promise made to the voters" in 2016.

The significance of the lawsuit goes beyond home deliveries. It represents an important early court test of Proposition 64, the law that legalized pot sales for adults in California. There have been numerous disputes over precisely what parts of the law mean, including those governing the size of cannabis farms.

The state Bureau of Cannabis Control, which wrote the rule, had no immediate comment on the lawsuit, which was filed late Thursday in Fresno County Superior Court.

The lawsuit asks the court to invalidate the rule and prohibit state regulators from enforcing it.

The rule "permits commercial cannabis deliveries to any physical address in the state," which conflicts with the authority of local governments to prohibit marijuana deliveries within their boundaries, the lawsuit said.

Marijuana companies and consumers had pushed for home deliveries because vast stretches of the state have banned commercial pot activity or not set up rules to allow legal sales, creating what's been called pot "deserts." Residents in those areas were effectively cut off from legal marijuana purchases.

Supporters said the problem was worse for the sick and frail, who would not be able to drive long distances to buy pot.

Because pot remains illegal on the federal level, it cannot be sent through the U.S. Postal Service. But people can get it delivered to their door in California. Under state rules, all cannabis deliveries must be performed by employees of a licensed retailer. Regulators say there are 311 active licenses to deliver pot.

The delivery rule sought to clarify what had been apparently conflicting regulations about where marijuana can be delivered in California.

The 2016 law said local governments had the authority to ban nonmedical pot businesses. But state regulators pointed to the business and professions code, which said local governments "shall not prevent delivery of cannabis or cannabis products on public roads" by a licensed operator.

The cannabis bureau had said it was merely clarifying what had always been the case: A licensed pot delivery can be made to "any jurisdiction within the state."

In addition to Beverly Hills and Santa Cruz County, plaintiffs include the cities of Agoura Hills, Angels Camp, Arcadia, Atwater, Ceres, Clovis, Covina, Dixon and Downey. Also participating are McFarland, Newman, Oakdale, Palmdale, Patterson, Riverbank, Riverside, San Pablo, Sonora, Tehachapi, Temecula, Tracy, Turlock and Vacaville.