SAN DIEGO (AP) — Californians on Tuesday voted to allow a law banning flavored tobacco products such as menthol cigarettes and strawberry gummy vaping juice to go into effect.

With about a quarter of the ballots counted, Proposition 31 won handily with 76.3% of the vote.

A campaign funded by tobacco giants, including R.J. Reynolds Tobacco Co. and Philip Morris USA, had effectively blocked the law passed two years ago. The $20 million campaign gathered enough signatures to put the issue on the statewide ballot.

Supporters of the ban, who included doctors, child welfare advocates and the state's dominant Democratic Party, said the law was necessary to put a stop to the staggering rise in teen smoking.

But tobacco companies pushed hard to keep from being shut out of a large portion of California's vast market. California's Republican party also opposed the ban, saying it would cause a giant loss in tax revenue. The independent Legislative Analyst's Office estimated it could cost the state tens of millions of dollars to around $100 million annually.

California becomes the second state in the nation, after Massachusetts, to enact a ban prohibiting the sale of all flavored tobacco products, including menthol cigarettes. A number of California cities, including Los Angeles and San Diego, already enacted their own bans.

It's already illegal for retailers to sell tobacco to anyone under 21. But advocates of the ban said flavored cigarettes and vaping cartridges were still too easy for teens to obtain. The ban makes it a crime to possess such products and retailers who sold them to kids could be fined up to $250.

The ban, which passed the Legislature with bipartisan support, also prohibits the sale of pods for vape pens, tank-based systems and chewing tobacco, with exceptions made for hookahs, some cigars and loose-leaf tobacco.