Environmentalists declared victory early Wednesday on a nationally watched campaign to ban fracking, the controversial oil-drilling technique, along with all new oil drilling, in Monterey County.

Despite being outspent roughly 30-1 by Chevron, Aera Energy and industry supporters, backers of Measure Z said they had sent a message with their effort, which passed by 56 to 44 percent.

“David beat Goliath in Monterey County’s stunning victory against oil industry pollution,” said Kassie Siegel, director of the Center for Biological Diversity’s Climate Law Institute.

“Despite spending millions, oil companies couldn’t suppress this grassroots campaign,” she said. “This triumph against fracking will inspire communities across California and the entire nation to stand up to this toxic industry.”

Monterey County becomes the sixth county in California to ban fracking, but it is the first one with a significant oil industry. The county ranks fourth statewide in oil production. Supporters said they hoped the measure would accelerate momentum on a national movement to ban fracking.

Although opponents spent more than $5 million against the measure, supporters won endorsements from Vermont Sen. Bernie Sanders, who visited Monterey County to speak in favor of the measure, actor Leonardo DiCaprio, United Farmworkers Union leader Dolores Huerta and other leading liberals.

The oil industry said the measure would make rules so difficult that all oil production could be affected.

“Hundreds of local jobs and millions of dollars in local revenue have been put at risk,” Karen Hanretty, a spokeswoman for the no campaign, said Wednesday. “It is unfortunate that proponents of Measure Z were not forthcoming about the real intent of Measure Z and its impact on 70 years of safe and responsible oil production in Monterey County.”

Fracking is a process in which companies inject water and chemicals underground to break rock formations and release oil and gas. Brown and state lawmakers have refused to ban it statewide, but local supervisors and voters have banned it in Santa Cruz, San Benito, Alameda, Butte and Mendocino counties.

Measure Z would continue to allow the roughly 1,200 existing oil wells in Monterey County to remain, most of which are located near San Ardo in the Salinas Valley. During the campaign, supporters said their goal was to reduce the risk of groundwater pollution from oil drilling, including potential future drilling in the Monterey Shale formation, and to push forward a statewide grass-roots movement.

The Monterey County measure will not only ban fracking, but also another oil production technique that uses acid to extract oil from underground. In addition, it would prohibit underground wastewater disposal from oil drilling after five years. There are about 35 wastewater injection wells in the county now.