These chemical compounds, often created in labs in China based on research conducted at western universities and pharmaceutical companies, are not regulated when they appear on the market and are hard to detect.

“And if you are someone who is regularly drug tested, it will not show up,” adding to the drugs’ appeal, Mr. Gerona said.

He traced the history of synthetic drugs back to Clemson University and a researcher, John W. Huffman, who was looking for ways to create a drug in the lab that could enhance the medicinal aspects of THC while eliminating the psychotropic effects.

In the course of his work, Mr. Huffman synthesized more than 300 compounds, and his work was published in academic literature.

Not long after, in about 2008, a synthetic compound began appearing on the street, called K2 in America and Spice in Europe. The main chemical agent, known as JWH-18, was named after the Clemson researcher.

Soon JWH-18 was showing up around the country and was eventually scheduled as a Class 1 narcotic.

The drug makers would have to evolve to stay one step ahead of law enforcement.

In the case of the drug in the Brooklyn outbreak, Pfizer established a patent for a synthetic cannabinoid it called AB-FUBINACA in 2009. The drug seems to have been abandoned by the company and was never tested on humans.