They called him Patient X.

The Berkeley boy had his first epileptic seizure when he was 4, and after that, they kept coming, up to 100 a day. His desperate parents tried a barrage of two dozen medications, plus a high-fat medical diet and autoimmune therapy.

But nothing worked — not until a British company let him try a marijuana-based drug.

Sam Vogelstein, now 17, was the only patient in an early test that was unheard of in medical circles. The high-concentration cannabidiol strain had never been given to children and was illegal in the United States, even though the drug had been stripped of its high-inducing chemical.

It worked. And now, after six years and a clinical trial led by UCSF, the drug is available for others. On June 25, the U.S. Food and Drug Administration approved Epidiolex for treatment of two severe forms of epilepsy, Lennox-Gastaut syndrome and Dravet syndrome.

It is the first time the FDA has approved a medicine derived from marijuana. It won’t work for every patient, but for Sam’s family, it’s everything.

“What I went through, I know, was not normal,” said Sam, a junior at Sterne High School in San Francisco. “It’s not something anyone should have to go through. I hope I’m able to somehow make a large impact.”

It started, seemingly, with a judo bow.

Evelyn Nussenbaum and her husband, Fred Vogelstein, were saying goodbye to a college friend who had spent the evening at their home. Sam let his head drop, like a martial artist, then snapped it back.

“Why did you do that?” his mother asked.

“I don’t know,” the 4-year-old said.

Two months passed. Sam did it again. This time, they were in New York visiting Vogelstein’s family. Sam bowed and didn’t know why. Soon, it was happening once a week. His twin, Beatrice, seemed unaffected.

Definitely a nervous tick, Vogelstein said. Definitely something more, Nussenbaum replied.

They fought about it, back and forth, not ready to receive a heavy truth. Eventually, they took Sam to the hospital for an electroencephalogram.

“They said he had a seizure disorder,” Nussenbaum said. “I didn’t know that meant epilepsy. When I looked it up, my heart dropped. I remember thinking, ‘Oh, my God, it’s epilepsy.’”

The misfiring of Sam’s electrical system changed the family’s trajectory. His disorder was an uncrackable riddle that doctors and medication could not solve.

The boy fell down a flight of stairs. He cracked a window pane with his head, and went facedown in a plate of spaghetti. “Glad I don’t remember that one,” he said. He didn’t have grand mal seizures, characterized by collapsing and twitching on the ground. Instead, for five to 20 seconds, his face would go slack and he would seemingly leave his body.

When Sam regained consciousness, things would be slightly different. At school, his classmates would angrily urge him — the line leader — forward. They didn’t understand why he was standing still. He would spend an hour learning a math formula, only to have a seizure and forget it.

His life was like a scratched DVD; entire portions were missing. Some medications helped, but many didn’t. And their side effects were severe: anger, full-body rashes, or hallucinations that bugs were crawling from holes in his skin.

More than 3.4 million people in the United States have epilepsy, but because of the brain’s complexity, relatively little is known about how to treat the disorder. As Sam got older, there were seemingly fewer options. Then Nussenbaum, a journalist who had given up her career to care for her son, found an article on cannabidiol in Seizure, a British medical journal.

Maybe this was the secret.

Known as CBD, the purified drug has no trace of tetrahydrocannabinol, or THC, the euphoria-inducing chemical in marijuana. In one study, cannabidiol had stopped seizures in rodents. It could work for Sam, too, his parents thought.

“We are out of options,” Nussenbaum thought. “How can I get cannabidiol?”

She and her husband joined an underground cannabidiol collective, but when they tested what they received they found more THC than CBD in the concoction. They had a family friend buy marijuana from a dealer in Oakland and purify it in her kitchen. But the process was long and costly, and it made her suburban home smell like pot. There had to be a better way.

Eventually, with the help of family friends, Nussenbaum and Vogelstein persuaded British company GW Pharmaceuticals to test a cannabis-based oil for epileptic children. The firm had previously gained market approval in the United Kingdom for another cannabis derivative, for treatment of multiple sclerosis. Sam would be their test dummy — the only one.

The one-person trial had to be done overseas because the U.S. government classifies marijuana as a Schedule 1 drug, the same tier as heroin. Sam’s parents paid thousands of dollars out of pocket for airfare, hotels and medical co-payments to make it possible.

“I knew we were going on a trip to London for whatever medical reason,” Sam said. “I don’t think I really understood what was happening. But it changed my life.”

Within days of traveling from Berkeley to London and taking the cannabidiol, Sam’s seizures plummeted from 68 to six per day, and then to zero. With no side effects.

Dr. Maria Roberta Cilio moved from Rome to join UCSF Benioff Children’s Hospital in 2011 and had been appointed as a professor of neurology and pediatrics in 2012 when she met Sam. Though she was still relatively new, she began lobbying the FDA for a compassionate use trial, in which illegal drugs can be used outside of a clinical trial.

“Sam’s life had completely changed because of CBD,” Cilio recalled. “For this particular patient, for him, it was a huge change.”

After four months, the FDA approved the trial. But the Drug Enforcement Administration was less convinced.

One day in 2013, agents unexpectedly showed up at Cilio’s office at UCSF and questioned her for two hours — a scene that reminded her of a crime show — about whether she had used drugs and how she would store the imported cannabidiol oil. In the end, they made her obtain a 965-pound safe for storing the medicine.

That May, Cilio began giving Epidiolex to Sam. His parents had ordered a special hemp oil through the mail as a makeshift medication during the four-month interim period. It wasn’t as effective.

Sam was the first patient to receive the drug, and 162 children and young adults in 11 epilepsy centers across the nation would follow, receiving 12-week courses of the drops.

Cilio’s research, published in 2015 in the Lancet Neurology, showed a 36.5 percent average reduction in monthly motor seizures, which affect muscle activity. In the last month of the trial, she said, some patients who once had hundreds of seizures a day were completely free of them.

“Drugs are normally only tested in adults first. This time, it was the opposite. The drug had never been used in humans, let alone children. It worked,” Cilio said.

“I feel that we followed the right path that was not easy,” she said. “I was not pro, and I was not con, about marijuana. I took it as I would have done any drug. I wrote a protocol that was strict and rigorous and accurate, and this is the reason the FDA approved it for the first time.”

How cannabidiol alleviates seizures at a molecular level, though, remains unclear. More studies are needed.

Recently, on the anniversary of Sam’s seizures stopping, the family celebrated by making ice cream sundaes at their Berkeley home. They sprayed whip cream on each other’s faces, and Nussenbaum got a perfect beard and mustache.

“Genius comes from the smallest of things,” Sam said, smiling. “I saw the can of whipped cream while my mom was shopping and knew just what I wanted to use it for.”

Sam wants to get his driver’s license. He wants to be a counselor at an epilepsy camp so he can help other kids who went through what he did. He might even get a job at a comic book store. This fall, he’ll start competing in fencing. He knows these are all things someone suffering from severe seizures can’t do. But that’s not him anymore.

Sometimes he thinks back to the London trip, when he first tried Epidiolex. On one of the last days, he went zip-lining 30 feet over Hyde Park, something that would have been unthinkable even a week earlier. For the first time in a long time, he felt like an average kid — and a healthy one.

Flying through the air, he felt free. He wasn’t Patient X. He was just Sam.

Lizzie Johnson is a San Francisco Chronicle staff writer. Email: ljohnson@sfchronicle.com Twitter: @LizzieJohnsonnn