Bill Cosby departs the Montgomery County Courthouse in Norristown, Pa., May 24. (Matt Rourke / Pool/European Pressphoto Agency)

— A judge on Tuesday ordered Bill Cosby to stand trial in a sexual assault case, clearing the way for a momentous showdown between the iconic comedian and prosecutors.

Judge Elizabeth McHugh took only a few moments to reach her decision after a contentious 3½-hour hearing in which Cosby’s defense team aggressively sought to attack the credibility of his accuser: former Temple University women’s basketball official Andrea Constand.

The 78-year-old actor sat listening intently, often rubbing his fingers across his chin, as his defense attorney, Brian McMonagle, blasted away at inconsistencies in statements given by Constand, who has said Cosby drugged and sexually assaulted her at his suburban Philadelphia estate 12 years ago.

Montgomery County, Pa., prosecutors opted not to call Constand as a witness Tuesday at a hearing that provided the first detailed courtroom airing of the case against Cosby. Instead, prosecutors relied heavily on an interview that police conducted with Constand in January 2005, about a year after she says Cosby gave her pills at his estate that made her so woozy that her legs went “rubbery” and she experienced “blurred vision.”

The hearing was held to determine whether there is enough evidence for a trial to be scheduled on charges of aggravated indecent assault against Cosby, who has been accused of sexual assault by at least 58 women but is facing criminal charges only here in Pennsylvania. Prosecutors here had previously declined to charge Cosby, citing a lack of evidence.

McMonagle, his voice rising in anger and incredulity, pushed for a full-throated rebuttal of the prosecution’s case.

He pressed prosecution witnesses about Constand’s statement to police that she had not had contact with Cosby after the alleged assault.

“You knew that was a lie!” McMonagle said to Katherine Hart, who was involved in the early stages of the investigation and is now retired.

In fact, McMonagle said, phone records later showed that Constand had called Cosby a dozen times. The defense also drilled down on corrections Constand made to a transcript police had made of her interview, including deleting the words “nothing sexual” in her account of an evening she spent with Cosby at a casino.

The defense attorney got prosecution witnesses to confirm that Constand had provided investigators with different possible months for when the 2004 incident took place. Constand also purportedly told police in her native Canada that Cosby had assaulted her after an outing to a Chinese restaurant, rather than after a private dinner at his home.

“Stop this!” McMonagle said in a booming voice to McHugh, urging her to dismiss the case.

For all the potential weaknesses exposed by McMonagle, prosecutors were able to lean on the jarring details of the alleged assault that Constand provided to police. According to detectives who interviewed her, Constand said Cosby pushed her to take pills and drink wine at his house when she was vulnerable emotionally because of uncertainty about her career and had sought his mentorship.

Cosby watched as Hart, a former detective, read a statement in which Constand recalled Cosby telling her that she’d feel better if she took the pills, which he said were Benadryl, and to “taste the wine.”

“Nurse it,” Cosby told her.

She was left with “blurred vision,” according to the statement Hart read, and had “no strength in her legs.”

Cosby betrayed few emotions during the hearing, but he shook his head when Hart, reading from the statement, said Constand remembered him touching her breasts and vagina.

Later, Cosby cupped his chin in his fist as John Norris, the Cheltenham, Pa., police chief, quoted Cosby as saying “I enjoyed it” during an interview in which he recalled his sexual contact with Constand.

Defense attorneys were able to elicit a potentially important nugget from prosecution witnesses: Constand, according to transcripts of her statements, never told detectives that she said “no” to Cosby’s advances.

“At no time did she ever tell Mr. Cosby, ‘No, get your hands off me. I don’t want to touch your penis’?” McMonagle asked Hart.

“No,” the detective said.

Cosby has denied the charges. A trial date has not yet been set. Tuesday’s proceedings played out before a crowded courtroom. Among those on hand was Gloria Allred, the celebrity Los Angeles attorney who represents more than two dozen Cosby accusers, including one woman — Judy Huth — who has filed a sexual battery civil suit against him.

Cosby, who had arrived for an earlier hearing in a lumpy sweater and carrying a cane, appeared Tuesday in a sharp gray suit and burgundy tie. He was escorted to the courtroom by two large men, one in sunglasses. He leaned heavily on the arm of one of the men as he approached the courtroom door.

“We’re entering the courtroom now,” the man told Cosby, who has failing eyesight and took short, careful steps.

When it was over, Cosby stood at the defense table, gazing toward the judge.

“Mr. Cosby, good luck to you, sir,” the judge said.

The entertainer responded in a loud, steady voice: “Thank you.”