The caretaker opens the door to the lab, which is adorned with a “Caution: Radioactive Materials” sign and a notice to authorities that “this is a research facility that is known to and authorized by the Contra Costa County Sheriff’s Office, all San Francisco DEA personnel, and the state and federal EPA authorities.”

The lab is cramped and dusty and smells of age, but feels very much in use and very much alive — it is as if Shulgin were simply out to lunch. Jars, flasks, beakers and test tubes crowd every counter. Plastic tubing crisscrosses metal pipes that hold all manner of glass implements in midair. My eyes are drawn to a rack of glass test tubes with labels scrawled in Shulgin’s handwriting. Here be dragons, I think to myself.

The writer in Shulgin’s lab.

“Don’t get too excited,” the caretaker says with a smile as I finger one of the tubes. “There’s nothing illegal in here.”

I think about the razor’s edge of the law Shulgin danced on for most of his life, the pirouettes one must spin to be both a hero to drug legalization activists and an essential ally of the D.E.A., to be in a position to synthesize psychedelics in plain sight of the authorities while users of those same drugs end up in jail for years.

Shulgin worked under a Schedule I D.E.A. research license for decades, which allowed him to study drugs that were officially deemed to have no medical value and a high potential for abuse. In return, he gave talks to drug agents, supplied drug samples, and provided expert testimony in drug cases.

“That was his Faustian bargain,” recalled Rick Doblin, the psychedelic activist who founded the Multidisciplinary Association of Psychedelic Studies (MAPS) in 1985. “In order to do his work, he had to be useful to the D.E.A.”

He was, to a point. And then he really, really wasn’t.

In 1991, shortly after authoring the D.E.A.’s definitive guide to federal drug laws, the Shulgins released PiHKAL: Phenethylamines I Have Known and Loved. The self-published book was half autobiography of Shulgin and his wife Ann, half account of his decades of research into psychedelic compounds, replete with instructions on the synthesis and dosage of hundreds of psychedelics, as well as vivid trip reports by Shulgin and the small group of friends on whom he’d test his latest creations. The book was a bestseller, the timing impeccable. As more and more people plugged into the World Wide Web in the early 1990s, PiHKAL ended up on the drug resource website Erowid, introducing a new generation to the wonders of psychedelic chemistry.

The D.E.A. was not pleased. Agents raided Shulgin’s property in 1994, and he was asked to give up his Schedule I license.

“I’m not doing anything illegal,” Shulgin would often say. And, in a sense, he was right. As a 2005 New York Times profile pointed out, “Many of the drugs in his lab weren’t illegal because they hadn’t existed until he created them.”