A Philadelphia nun on trial for alleged drunk driving and crashing into an auto-repair shop in South Jersey has invoked a relatively new defense: sleep driving after taking a sleeping pill.

Lawyers for Sister Kimberly Miller say the nun experienced an adverse reaction to Ambien, losing four hours of her life after taking the drug, drinking a glass of Mont LaSalle altar wine and going to bed.

When Miller - who had consumed two glasses of wine earlier in the night at a book fair- woke up, she testified, she was at a Washington Township police station, 20 miles from St. Veronica's, her North Philadelphia convent.

Miller was charged with driving under the influence after crashing her Chevy Impala into a Meinke shop on Route 42 in Turnersville on Nov. 7, 2015. Police said her blood alcohol level was .16, twice the legal limit in New Jersey.

During a nearly six-hour trial in municipal court Wednesday, defense lawyers and an expert witness argued the so-called "Ambien defense," contending Miller had no recollection of the incident. "She didn't know what she was doing," said lawyer Jeffrey Lindy, one of two Philadelphia lawyers handling her case.

For about the past decade, lawyers across the country have used a similar strategy to argue that their clients weren't at fault for crashes and other incidents, including some violent crimes. A study of six sleep-driving DUI cases, outlined in a a 2013 medical journal, found that three defendants settled for lesser charges, two were found guilty and one was acquitted.

In one of the earliest Ambien defense cases, which occurred in New Jersey, an appeals judge overturned a Somerset County woman's drunk-driving conviction in 2009, finding that she had no way to know sleep driving was a potential side effect of the drug.

"She arose without having any idea whatsoever that she got in the car and had an accident," her attorney Richard Usland said in an interview Thursday. "The major thrust in that case was the fact she had no warning that sleep driving would occur."

Usland, a former prosecutor, said he has argued at least a dozen Ambien defense cases. He currently has three cases pending - two in North Jersey and one in Kentucky in which a man who took the drug sleep drove to a Walmart, bought a pack of cigarettes, a lighter and a pack of gum, and then got into an accident after leaving the store, he said.

The North Jersey incident happened in September 2006 - six months before Ambien and other makers of insomnia drugs were ordered to include a warning that the pills could leave patients susceptible to sleep-driving.

Since then, it's become clear that the sleep aids can impair driving, though the degree to which they affect someone's legal culpability is not. Miller testified in court Wednesday that she was unaware of the risks - that there had been no warning from her doctor or pharmacist.

In May 2013, the U.S. Food and Drug Administration began recommending that those who take extended-release sleep medications should avoid driving the next day due to the effects of the drugs. And a recent study found that, for drivers age 70 and older, Ambien may lead to higher risk of crashes.

Miller, the nun, is 41. A high school theology teacher and librarian and member of the Sisters, Servants of the Immaculate Heart of Mary order, she testified that she had a history of sleep walking that began as a child as a result of post traumatic stress.

"These episodes are not predictable," Fran Gengo, clinical pharmacologist and professor at the DENT Neurologic Institute in Batavia, N.Y., testified Wednesday at Miller's trial. "Patients can take it for years without side effects."

It's hard to tell precisely how often sleep-driving incidents happen. One study notes in its abstract that they are "statistically rare events, but due to the billions of doses prescribed each year may still result in numerous DUI related arrests and accidents."

In an eight-page report submitted in Miller's case, Gengo said her behavior clearly fits the pattern of an adverse reaction to Ambien. Besides sleep driving, activities reported caused by the drug can include sleep walking, eating food, talking on the phone and having sex, Gengo wrote.

"Patients who engage in driving while in the midst one of these episodes will typically be driving without a preplanned destination or purpose, will be dressed in somewhat unusual fashion, and have no recollection of how they arrived at where ever they stopped," Gengo wrote. "All of these are the case for Sister Miller."

Last month, a North Carolina man was acquitted of shooting up his home, assaulting his wife and firing at police after jurors determined he was under the influence of the drug and didn't know what he was doing.

"We actually had a couple of people who were on the jury and had taken Ambien (not during the trial)," attorney Mike Greene told North Carolina Lawyers Weekly. "I think they were aware that sometimes people can do certain things when they take Ambien that are crazy."

Kerry Kennedy, the daughter of Robert F. Kennedy, was found not guilty of drugged driving in 2014 after a July 2012 crash into a tractor-trailer on a New York highway while under the influence of Ambien; she said she mistakenly took the drug.

But the approach doesn't always work: In New York last year, a man accused of killing the mother of his son argued that Ambien made him become violent and unable to remember fatally strangling her. He was found guilty and sentenced to 20 years to life in prison.

Miller, in the meantime, also has another advantage in the trial. The judge in the case tossed the blood alcohol results on a technicality - police had not continuously monitored Miller for 20 minutes before administering the Breathalyzer. The judge is expected to rule next Wednesday.

Police witnesses said they smelled alcohol on Miller's breath and that she had bloodshot, watery eyes and that she failed two field sobriety tests and refused to take a third. A corked half-empty bottle of wine was found in her car, police said. If convicted as a first-time offender, Miller's driving privileges could be suspended in New Jersey and she could be fined up to  $900 and receive a possible 30 days in jail.

Usland, who is not involved in Miller's case, believes the defense made a strong Ambien argument, although it may have been weakened by her admission that she consumed wine, too. The same adverse reaction can occur without any alcohol, he said.

"People's behavior is very bizarre on this medication," Usland said. "It's a valid defense because it would be difficult to prove the criminal intent to commit the offense."

Miller, a faculty member at Little Flower High School for Girls in Philadelphia, was placed on administrative leave by the Archdiocese. Lindy said his client hopes to get her job back. "She loves teaching."

mburney@phillynews.com | 856-779-3814 | @mlburney