Alexander "Sasha" Shulgin, who has died aged 88, was a pioneering and fearless scientist, but his chosen discipline – the design and synthesis of psychedelic drugs – was one of the most maligned and least understood. Shulgin invented hundreds of new psychedelic drugs, which he tested on himself, his wife, Ann, and friends, documenting their preparation and effects. But he wasn't satisfied with mere discovery – he argued passionately for the rights of the individual to explore and map the limits of human consciousness without government interference.

He was most famously responsible for the emergence of one of the world's most enduringly popular recreational designer drugs, 3,4-methylenedioxy-N-methylamphetamine, also known as MDMA, or ecstasy. He did not invent it, since MDMA had been designed by the pharmaceutical firm Merck in 1912 in a bid to produce a blood-clotting agent. However, Shulgin was responsible for creating a new and easier synthesis of it.

At the time he was researching a related chemical, MDA, and was tipped off in 1976 by a young colleague about the unusual activity of MDMA. He introduced the material to a psychiatrist friend, Leo Zeff, who was so astounded by the drug's powers that he delayed his retirement and travelled the US administering the drug to thousands of patients. The drug found its way into Dallas nightclubs, including the Starck Club, and on to the Balearic island of Ibiza, fuelling the 1980s acid house dance-drug craze. It was not Shulgin's intention to launch a global drug culture, nor to have that compound consumed with such abandon by millions of people. But it was his connection with this drug that made him a folk hero for the counterculture, known as the "godfather of ecstasy", and a folk devil for many outside it.

Shulgin was born in Berkeley, California, to a Russian immigrant father and an American mother, both teachers. He first studied organic chemistry at Harvard but dropped out and joined the US Navy at the age of 19. The 2011 biopic Dirty Pictures tells how, while at sea, he decided to memorise a chemistry encyclopedia, thinking it would be a "neat challenge".

After leaving the navy, Shulgin received a bachelor's degree in 1949 and a doctorate in biochemistry in 1955 from the University of California, Berkeley. Throughout the late 1950s he carried out postdoctoral work in psychiatry and pharmacology at the University of California, San Francisco, and after a brief stint at Bio-Rad Laboratories took a job at Dow Chemical, where he worked on synthesising pesticides. One of these, Zectran, was the world's first biodegradable pesticide and made the company so much money that it gave Shulgin free rein in the laboratory to pursue his own interests.

Soon his focus had turned to the creation of psychedelic drugs. Like many intellectuals in the 50s on both sides of the Atlantic, he had taken, and been fascinated by, mescaline – a hallucinogenic drug found in the peyote cactus that is used in Central and Latin America in traditional religious, healing and shamanic contexts. When Shulgin took mescaline for the first time in the late 50s he accessed memories and feelings of wonder that he had not felt since he was a boy.

"The most compelling insight of that day was that this awesome recall had been brought about by a fraction of a gram of a white solid, but that in no way whatsoever could it be argued that these memories had been contained within the white solid," he wrote. "Everything I had recognised came from the depths of my memory and my psyche. I understood that our entire universe is contained in the mind and the spirit. We may choose not to find access to it, we may even deny its existence, but it is indeed there inside us, and there are chemicals that can catalyse its availability."

He realised that other forms of the drug might be possible if he were to tinker with the basic molecular structure, and then made that task his life's work. He left Dow in 1965 and began work in a laboratory he had constructed behind his house. Photographs of him from that time in his white lab coat with a briar pipe in his mouth and beret angled on his head depict an almost impish character. But he would soon establish himself as the world's foremost drug designer.

In interviews, he was much more animated when discussing the most recondite chemical matters than his experiences with the drugs themselves. "Chemistry is pornography in disguise, you just have to know which functional group to look at," he said.

Shulgin laboured in his ramshackle garden shed laboratory under the protection of the Drug Enforcement Administration, for which he provided chemical expertise in drugs cases. He was granted a licence to produce Schedule I substances, equivalent to Class A in the UK, for many years after he left Dow.

Often listening to music by Prokofiev, Shostakovich or Rachmaninov, he would perform his chemistry amid pipes and bubbling glassware. When he was satisfied that he had invented something worthwhile, he would ingest the new chemical – first by deciding on the minimum amount required to have an effect, then taking 1/1000th of that dose, gradually increasing the dose until he felt effects. He would then measure them against his own scale of the transcendental experiences they induced.

In 1994 the DEA and other agencies suddenly raided Shulgin's lab and found samples of drugs sent to him anonymously for chemical testing. The outcome was the termination of his licence to work with Schedule I materials. He was fined $25,000.

Shulgin was upset that his discoveries were being commercialised and that this led to deaths, including three overdoses from the drug 2C-T-7 in 2000. "I'm disturbed by the fact that you get someone who wants to make a pile of money and doesn't give a damn about the safety or the purity," he said. "It's a motivation that I'm uncomfortable with. People using psychedelics, I'm not uncomfortable with. I consider it a very personal exploration. But I'm very disturbed by the overpowering of curiosity with greed."

He continued to innovate and publish his work, always with accurate dosage information. His work made other people billions of illicit dollars, but his own later years were marked by financial worries over his healthcare bills, though friends and followers were supportive. Two books, Pihkal: A Chemical Love Story (1991) and Tihkal: the Continuation (1997), both written with Ann, are considered classics in both the fields of organic chemistry and illicit drugs synthesis.

He is survived by Ann, his second wife, whom he married in 1981, and her three children. His son, Ted, died in 2011.

• Alexander Shulgin, chemist, born 17 June 1925; died 2 June 2014

• Why did Shulgin become known as the godfather of ecstasy?