BOSTON – A controversial temporary ban on the sale of all vaping products in Massachusetts can stand for now, a judge ruled Monday, saying the ban as written is likely unlawful but halting it immediately would "contravene the public interest."

The decision, denying a request for an injunction from the vaping industry, is a partial win for Republican Gov. Charlie Baker, who enacted the strongest measure taken by any state to combat a national outbreak of vaping-related lung injuries.

But Suffolk County Superior Court Judge Douglas Wilkins, in a written order, questioned the legality of components of Baker's executive order and said the four-month ban issued Sept. 24 can only remain if the commonwealth addresses the problems.

The judge gave the state until Oct. 28 to rewrite the ban. He also said the state must hold a public hearing, as required by state law, so affected vape shops and others can weigh in, and provide a fiscal impact to businesses.

Wilkins said the order covering nicotine products must be resubmitted as an emergency regulation. He noted the state has not addressed whether an "emergency" exists for adult users of nicotine-vaping products; instead it relied predominantly on an "epidemic" among young users.

"While the plaintiffs have shown a likelihood of success, the balance of harms weigh in defendants’ favor in some respects, and an immediate injunction against the entire order would contravene the public interest," Wilkins wrote. "The court therefore allows the defendants an opportunity to cure the defects identified above."

More:Massachusetts vaping ban allowed to stand for now amid court challenge

The judge's decision comes after courts in Michigan and Oregon overturned recent bans in those states on the sale of flavored vaping products.

Tony Abboud, executive director of the Vapor Technology Association, said in a statement the group was pleased in part, but regretted the judge's decision "to allow this improper ban to stay in place for a week while the State considers other regulatory alternatives." He asked that the ban be suspended immediately.

Baker's spokeswoman Lizzy Guyton said in a statement: "The administration maintains that the order was properly issued pursuant to the Commissioner’s emergency powers and will work with the Attorney General’s Office on next steps.”

The Vapor Technology Association, the lobbying arm of e-cigarette companies and vaping products, asked the judge to intervene to halt the ban, arguing the state acted without an accurate understanding of what's caused the illness and that vape shops and companies have suffered irreparable damages. Massachusetts vape shops have brought a similar lawsuit.

In his 32-page order, Wilkins said vaping companies have "certainly suffered, and will suffer very great financial impact" and are "likely to show that the order is unlawful" as currently written.

The plaintiffs argued vaping products with THC, not nicotine, have caused the medical issues and that the total ban was an executive overreach.

More:Vaping-related illnesses increase again, but at a slightly slower rate. At least 33 have died

The Centers for Disease Control and Prevention said last week the multistate outbreak of illnesses associated with the use of e-cigarettes is now responsible for at least 33 deaths and 1,479 cases of pulmonary disease. One death has been reported in Massachusetts.

Most of the patients report a history of using vaping with THC products. THC is the mind-altering compound of marijuana that produces the “high."

The judge's decision came after a hearing Friday where health experts took the stand as witnesses.

Michael Siegel, professor of community health sciences at the Boston University School of Public heath, said the ban will result in many ex-smokers, who had switched to vaping, to return to smoking cigarettes. He also said it will create a new "black market" of unregulated vaping products.

"From a public health perspective, I believe this regulation or order does not serve the interests of the public’s health and it actually significantly harms the health of some," Siegel said.

Monica Bharel, commissioner of the Massachusetts Department of Public Health, said her department recommended Baker take emergency action in August after learning of the "acute and increased reporting" of vaping patients with pulmonary illnesses.

"My job as the commissioner of the department of public health is to look at the safety and health of individuals," Bharel said. "Looking at that, we made this decision."

More:Massachusetts vaping ban allowed to stand for now amid court challenge

Joseph Terry, the attorney for the vapor association, pressed Bharel whether she agreed that youth vaping was "not an emergency but a long-term issue." She did not voice disagreement, but said the ban was intended to give health officials "a pause" to investigate precisely what is causing the illnesses.

"Isn't it important to know what's in them before you ban an entire industry?" Terry asked.

The Massachusetts Department of Public Health reported its first vaping-related death this month, a woman in her 60s from Hampshire County. So far, 212 cases of possible vaping-related illnesses have been reported to the state; 29 have been ruled probable.

Reach Joey Garrison on Twitter @joeygarrison.