The bill would also place a 75% excise tax on vaping products and require health insurers, including the state's Medicaid program, to cover tobacco cessation counseling.
"This nation-leading step will save lives," Democratic House Speaker Robert DeLeo said.
The ban was passed by the Senate early Thursday before the legislature broke for a holiday recess. It had earlier been passed by the state House of Representatives and now goes to the desk of Republican Gov. Charlie Baker.
Baker hasn't indicated whether or when he will sign the ban, but its chances are good. In September, he had declared a public health emergency and ordered a temporary ban on the sale of vaping products.
The legislation would immediately ban the sale of flavored vaping products and would outlaw sales of menthol cigarettes starting June 1, 2020.
The legislation responds to growing concern about the health effects of vaping products, including deaths.
It is the first such statewide legislation in the country, according to Matthew Myers, president of the Campaign for Tobacco Free Kids.
"This legislation is a critical step to help end the worsening youth e-cigarette epidemic and stop tobacco companies from using appealing flavors to lure kids into a lifetime of addiction," he said in a written statement. "It would make Massachusetts the first state in the nation to prohibit the sale of all flavored tobacco products."
The American Cancer Society Cancer Action Network also called it first-in-the-nation legislation.
"More than 80% of teens who have ever used a tobacco product started with a flavored product, and the tobacco industry knows this," the organization said in an emailed statement.
Studies have shown menthol cigarettes are consumed disproportionately by young people and minorities, and anti-tobacco groups and health experts have argued menthol has been marketed in particular to African Americans.
A major retailers' organization called the legislation disappointing.
"We are disappointed the legislature supports bills that disproportionately impact communities of color and have disastrous implications for public health, public safety, state tax revenue and jobs in the Commonwealth," Jonathan Shaer, president of the New England Convenience Store Owners and Energy Marketers Association said in a statement.
He called menthol and mint tobacco as "legal, adult products that aren't associated with youth overuse."
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.