Cops can no longer pull over cars when they smell the distinctive odor of pot wafting from vehicles, the state’s highest court said yesterday in a controversial ruling that has law enforcement and legal experts raising alarms about stoned drivers endangering Bay State roads.

“I think it turns logic on its head,” said Martin Healy, chief legal counsel for the Massachusetts Bar Association. “The decision is not based in the reality of everyday happenings. Sometimes the court looks at cases and gets lost in the law. This is a public safety issue.”

Wayne Sampson of the Massachusetts Chiefs of Police Association added, “That is a very troubling decision with regards to public safety.”

A divided Supreme Judicial Court voted 5-2 that police aren’t allowed to stop a car if they only have “reasonable suspicion” that the driver is committing the civil infraction of possessing marijuana. The case involved a 2012 stop by a New Bedford cop who reported smelling pot coming from a moving vehicle.

“Impaired drivers should be a concern for everyone. This doesn’t help that,” Stoughton police Chief Paul Shastany said. “If you see an accident, you ask, ‘Why didn’t police keep them off the road?’ Society needs to modify their expectations on what they want police to do.”

Justice Robert J. Cordy, who wrote a dissenting opinion joined by Justice Francis X. Spina, said the court went too far and that civil marijuana violations committed in moving vehicles “do implicate concerns regarding traffic and automobile safety.”

“In my view, there is no constitutionally based reason to distinguish stops for civil marijuana violations (occurring in motor vehicles) from stops for civil motor vehicle violations,” Cordy stated. “Reasonable suspicion of a civil violation is enough.”

Cordy likened police vigilance on pot use behind the wheel to the state’s ban on texting while driving.

Arlington police Chief Frederick Ryan agreed, saying, “I think with the onset of medical marijuana, combined with the pending petition for recreational marijuana, it’s going to get extremely challenging for law enforcement to keep impaired drivers off the road. This is another challenge. The odor of burning marijuana is a very distinctive odor and it’s been used by law enforcement officers to establish probable cause for years. This creates an additional challenge for officers.”

Since the possession of small amounts of marijuana was decriminalized in 2008, the state supreme court has systematically issued rulings protecting pot smokers.

The court has previously ruled that the smell of burnt marijuana is not enough for a police officer to order someone out of a vehicle when they have been stopped for some other reason. The court also ruled that the odor of weed — burnt or otherwise — does not give police probable cause to search a vehicle without a warrant.

Writing for the majority in yesterday’s ruling, Justice Margot Botsford stated, “We are disinclined to extend the rule that allows vehicle stops based on reasonable suspicion of a civil motor vehicle offense to stops to enforce the civil penalty for possession of one ounce or less of marijuana.”