CARPINTERIA, Calif.—On a recent sunny morning in this beach town near Santa Barbara, realtor Gary Goldberg ran into Das Williams on the street and raised a concern: A persistent skunky aroma had required him to knock $18,000 off the sale price of a condo.

“It smelled like marijuana,” said Mr. Goldberg, adding that buyers threatened to pull out because of the odor.

Mr. Williams, a Santa Barbara County supervisor who helped craft regulations for large cannabis farms here, assured the realtor that he was doing everything he could to tamp down the smell. The argument over odor is part of an acrimonious debate over how to regulate the region’s growing marijuana industry, pitting farmers against some residents.

Cities and counties across California are grappling with where to grow cannabis for the nation’s largest legal market. More than two years after the state stopped requiring a doctor’s note to buy the drug, but left it up to locals to decide where it should be grown, less than half its 58 counties allow commercial farming.

Some counties like Sonoma, in the heart of wine country, have limited pot farms’ size and their proximity to residential areas. Calaveras County, located in the Sierra Nevada foothills, quickly permitted hundreds of grows, then reversed course and banned them. Santa Barbara rushed in with few reservations at first and growers here captured 886 provisional cultivation licenses, more than any other county, according to the state. Most farmers here hold multiple permits to increase the size of their operations.