NORRISTOWN, Pa. -- Bill Cosby's chief accuser could have been made woozy either by the cold and allergy medicine Benadryl or by quaaludes, an expert testified Thursday as the prosecution rested in the comedian's sexual assault retrial.

The identity of the pills that Cosby gave Andrea Constand before a 2004 sexual encounter at his home has been one of the most enduring mysteries of the case.

Constand testified that Cosby gave her three blue pills that knocked her out and then he violated her. Cosby, now 80, has said he gave her Benadryl to help her relax and that she consented to a sexual encounter.

Dr. Timothy Rohrig, a forensic toxicologist called by prosecutors, testified Thursday that Benadryl's main ingredient can cause sedation, "mental clouding" and even short-term amnesia, as well as muscle weakness and clumsiness.

He said Benadryl's manufacturer indicated it produced the medication in blue tablets until 2010. The company's website shows that an "allergy plus congestion" variety currently comes in blue.

Rohrig said quaaludes -- the 1970s-era party drug that Cosby has acknowledged giving to women before sex -- also have a tendency to make people sleepy.

Prosecutors rested their case after Rohrig got off the witness stand. The defence immediately asked Judge Steven O'Neill to acquit Cosby and send jurors home, arguing prosecutors hadn't proved aggravated indecent assault charges. O'Neill refused.

The defence also contended there's no evidence to prove the alleged assault happened within the 12-year statute of limitations. Prosecutors countered that Constand and Cosby have both said the encounter was in 2004, pointing out Cosby was arrested in late 2015, just before the deadline to charge him.

As the legal wrangling continued, Thursday's testimony focused on the unidentified drug that Cosby gave Constand on the night she says he molested her.

Constand said Cosby called the pills "your friends" and told her they would "help take the edge off."

She testified earlier this week that Cosby refused to tell her what they were when she confronted him about two months later. Her mother testified that Cosby told her in a January 2005 phone conversation that he'd have to look at a prescription bottle and would send the answer to her by mail.

She said he never did.

Cosby said in a subsequent police interview that he gave Constand 1 1/2 tablets of Benadryl to help her relax, then fondled her breasts and genitals. He said Constand never told him to stop.

Cosby, in a 2005 deposition read to jurors by a police detective, said he obtained seven prescriptions for quaaludes from his doctor in Los Angeles in the 1970s, ostensibly for a sore back, but added he did not use them himself because they made him tired.

He said he gave quaaludes to women he wanted to have sex with, using them "the same as a person would say, 'Have a drink."'

Rohrig, the director of a regional forensic science centre and medical examiner's office in Wichita, Kansas, called quaaludes "an old-timey sedative, hypnotic drug" that at one time were believed to be an aphrodisiac.

Quaaludes have been illegal in the U.S. since 1982. They're still legal in Canada and parts of Europe, Rohrig said.

The expert testimony came on the ninth day of Cosby's retrial on sexual assault charges that could send the "Cosby Show" star to prison for years.

A day earlier, Cosby's lawyers began their case by calling their star witness to the stand, countering the harrowing accounts of a half-dozen accusers with a woman who says Constand mused about framing a celebrity in hopes of a big payday.

Temple University academic adviser Marguerite Jackson testified that Constand, Temple's women's basketball operations director, spoke to her on a February 2004 road trip to Rhode Island about fabricating sexual assault allegations against a high-profile person so she could "get that money" from a lawsuit.

Cosby paid Constand nearly $3.4 million in 2006 to settle a civil lawsuit, and his lawyers call her a "con artist" who set him up.

Jackson's account was immediately challenged by prosecutors, who suggested she was not on the trip on which she says her conversation with Constand took place.

Cosby's lawyers lost their fifth bid for a mistrial over the prosecution's treatment of Jackson.

The defence argued as court opened Thursday that prosecutors were out of line for implying the defence was wrong to help Jackson write a statement outlining her claims about Constand. Prosecutor Stewart Ryan irked Cosby's lawyers during Jackson's cross-examination on Wednesday by repeatedly saying they "created" her affidavit.

Ryan highlighted differences between the Jan. 22 affidavit and one that Jackson wrote on her own last year, getting Jackson to concede that Cosby lawyer Kathleen Bliss had her add quotes and make other changes to the second document.

O'Neill said there were "simply no grounds for a mistrial" and that Cosby's lawyers were raising the issue too late. He added that it didn't appear the defence did anything wrong, nor were prosecutors wrong to question their involvement.

O'Neill blocked Jackson from taking the stand at Cosby's first trial last year, ruling her testimony would be hearsay after Constand told the jury that she did not know her. That trial ended without a verdict after jurors deadlocked. The judge changed his mind about Jackson for the retrial, giving the defence case a huge boost.

The Associated Press does not typically identify people who say they are victims of sexual assault unless they grant permission, which Constand has done.