Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

San Francisco supervisors voted unanimously Tuesday to boost the legal age to buy tobacco products from 18 to 21, despite arguments from opponents that cities and counties cannot trump California law.

San Francisco becomes the second-largest city after New York City to raise the minimum age to buy cigarettes and other tobacco products, including e-cigarettes. Hawaii and Boston also require tobacco buyers to be 21.

Supervisor Scott Wiener, chief sponsor of the legislation, said raising the age will discourage young people from turning into lifelong smokers.

Read More: Hawaii Becomes First State to Raise Smoking Age to 21

The issue is gaining traction nationally. A report last year by the Institute of Medicine found that 90 percent of daily smokers first tried a cigarette before 19.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Opponents argue that California law sets a minimum age of 18 and that the provision prohibits municipalities from setting a higher limit.

The small city of Healdsburg has suspended enforcing its new tobacco-age limit of 21 after a national tobacco retailer group threatened to sue. Santa Clara County, on the other hand, has not done so.

Thomas Briant, executive director of the National Association of Tobacco Outlets, had urged San Francisco to hold off on voting until the state attorney general can issue a decision.

Read More: Cigarette Smoke Might Cause Infertility, Early Menopause, Study Shows

Briant said 18-year-olds are adults when it comes to voting, serving in the military or signing a contract — and smoking should be no different.

Attorney General Kamala Harris has no legal opinion pending, a spokeswoman said.

San Francisco's city attorney called the proposed ordinance legally sound. The ordinance goes into effect June 1.