Psychedelic drugs are getting a makeover, with scientists exploring their potential in treating debilitating conditions like cluster headaches, addiction or anxiety, with promising results.

That's despite the fact that very few researchers are legally allowed to study psychedelics, largely because of LSD's decades-old reputation as a counterculture drug that sparked bad trips.

Back in the 1960s, LSD was touted as a tool to shed social conventions and fast-forward to enlightenment – or as LSD advocate Timothy Leary memorably said, "Turn on, tune in, drop out."

He was hardly the first to feel the chemical's allure. Back in the 1930s, Swiss chemist Albert Hofmann had shelved LSD after first testing it as a treatment for heart disease. But he couldn't shake the feeling that there was something more to it. After accidentally ingesting a bit and having a mild psychedelic experience, Hofmann decided to go further.

He eats 250 micrograms of LSD and, scientist that he is, starts journaling his experience. He only gets one entry down before he starts having really intense hallucinations. As he bikes home, he feels like time and space are standing still and objects around him are warping and wavering in weird shapes.

The next day, he writes, "A sensation of well-being and renewed life flowed through me... everything glistened and sparkled in a fresh light."

LSD seems to shut off certain controls in the brain, allowing signals from one part of the brain to flow unchecked to other regions – particularly the regions that process sensory inputs from the outside world and the regions that define our sense of self. This might explain why LSD can cause hallucinations. It's also why it could plausibly be beneficial to treat depression or anxiety, allowing signals in the brain to bypass pathways that aren't working so well.

Years of experimentation with LSD both in the laboratory and as a recreational drug suggest that it is physically and mentally safe for healthy individuals. But it can also bring on terrifying hallucinations and sensations, including anxiety and paranoia, especially if people aren't prepared for the experience.

In the 1950s, the U.S. Army tested LSD's potential to incapacitate enemy soldiers, but it turned out to be too expensive and difficult to deliver by aerosol. The CIA also tested it as tool for mind control by administering it to people, sometimes illegally and without their knowledge or consent, in the notorious Project MKUltra.

In the early 1960s, it was embraced by a growing counterculture movement searching for mind-altering experiences through art and music from groups like Jefferson Airplane and the Grateful Dead. LSD became simultaneously the most studied psychoactive drug in history and a leading cause for young people ending up in the emergency room. When the federal government banned LSD as a dangerous drug in 1971, it also restricted any further research on the drug and other known psychedelics.

But scientists hadn't forgotten its early promise.

Researchers have successfully fought for approval to study LSD, as well as other psychedelics such as psilocybin (the active compound in magic mushrooms) and MDMA, also known as the club drug ecstasy.

Carefully controlled studies have shown that LSD helps relieve debilitating cluster headaches, that psilocybin alleviates depression in terminal cancer patients, and that MDMA can help relieve the trauma of PTSD. Earlier this year, the FDA gave MDMA a " breakthrough therapy" designation, fast-tracking its path to Phase 3 clinical trials and and if all goes well, approval as a legal treatment.

Angus Chen is a journalist in New York. He's on Twitter @angrchen.

Freddy Arenas is an independent director who has created animations for The New York Times, California Sunday Magazine, Google and HBO Documentaries.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.