On a summer morning in 2013, Octavian Mihai entered a softly lit room furnished with a small statue of Buddha, a box of tissues and a single red rose. From an earthenware chalice, he swallowed a capsule of psilocybin, an ingredient found in hallucinogenic mushrooms.

Then he put on an eye mask and headphones and lay down on a couch. Soon, images flew by like shooting stars: a spinning world that looked like a blue-green chessboard; himself on a stretcher in front of a hospital; his parents, gazing at him with aching sadness as he reached out to them, suffused with childlike love.

Psilocybin has been illegal in the United States for more than 40 years. But Mr. Mihai, who had just finished treatment for Stage 3 Hodgkin’s lymphoma, was participating in a study looking at whether the drug can reduce anxiety and depression in cancer patients. Throughout that eight-hour session, a psychiatrist and a social worker from NYU Langone Medical Center stayed by his side.

Published Thursday, the results from that study, and a similar small, controlled trial, were striking. About 80 percent of cancer patients showed clinically significant reductions in both psychological disorders, a response sustained some seven months after the single dose. Side effects were minimal.