"This is a decisive step to help prevent another generation of San Francisco children from becoming addicted to nicotine," City Attorney Dennis Herrera said in a statement.
"The U.S. Surgeon General has warned that we’re in the midst of a youth vaping epidemic," Herrera added. "San Francisco is taking action to protect our kids.
"This temporary moratorium wouldn’t be necessary if the federal government had done its job. E-cigarettes are a product that, by law, are not allowed on the market without FDA review. For some reason, the FDA has so far refused to follow the law. If the federal government is not going to act, San Francisco will."
Backers said they hope the legislation will curb underage use of e-cigarettes, but critics said the ban will make it harder for adults to purchase an alternative to regular cigarettes.
The pushback to e-cigarettes is becoming a nationwide trend.
Texas Gov. Greg Abbott signed a law raising the legal age to buy e-cigarettes and tobacco in his state to 21 on June 7, joining 13 other states including California. Senate Majority Leader Mitch McConnell, R-Ky., and Sen. Tim Kaine, D-Va., also recently introduced a bill to raise the federal minimum age to buy tobacco.
From 2017 to 2018, e-cigarette use increased 78 percent among high school students and 48 percent among middle schoolers, according to the FDA.
San Francisco is a city that celebrates its marijuana culture, but it appears deeply opposed to other vices. Last year, voters approved a ban on the sale of flavored tobacco and in 2016, a tax on sugar-sweetened drinks.
E-cigarette maker Juul Labs, which is based in San Francisco, said it is opposed to youth vaping. The company is working on a ballot initiative that would regulate but not ban e-cigarette sales.
The Associated Press contributed to this report.