Bill Cosby was arraigned on a charge of aggravated indecent assault in a Pennsylvania courtroom on Wednesday, accused of drugging and sexually assaulting a Canadian woman at his home 12 years ago.

It is the first criminal charge brought against Cosby following allegations from numerous women that he drugged and assaulted them.

If convicted, the 78-year-old comedian/actor, who earned a good-guy image playing Dr. Cliff Huxtable on the Cosby Show, could face five to 10 years behind bars and a $25,000 US fine.

Guided by his lawyers, Cosby walked slowly into the court, using a cane and wearing a grey wool hoodie.

Cameras were not allowed in the building.

The 78-year-old comedian, who did not have to enter a plea today, said under oath that he had consensual sexual contact with the woman.

In court, he agreed to have no contact with the accuser.

Bill Cosby

Bill Cosby arrives at court to face a felony charge of aggravated indecent assault on Wednesday in Elkins Park, Pa. Cosby was charged Wednesday with drugging and sexually assaulting a woman at his home 12 years ago. (Matt Rourke/Associated Press)

He seemed at ease, laughing and chatting with his attorneys.

When the judge said, "Good luck, Mr. Cosby," he shouted: "Thank you!"

Cosby was fingerprinted and photographed at a nearby police station before being released. He also has had to surrender his passport. His next court hearing is scheduled for Jan. 14. 

"Make no mistake: We intend to mount a vigorous defence against this unjustified charge, and we expect that Mr. Cosby will be exonerated by a court of law," his attorney Monique Pressley said in a statement Wednesday. 

Prosecutors accuse Cosby of plying former Temple University employee Andrea Constand with pills and wine, then penetrating her with his fingers without her consent, while she was drifting in and out of consciousness, unable to resist or cry out.

She was "frozen, paralyzed, unable to move," Montgomery County district attorney-elect Kevin Steele said. In court papers, prosecutors said the drugs were the cold medicine Benadryl or some other, unidentified substance. Steele noted that Cosby has admitted giving Quaaludes to women he wanted to have sex with.

The TV star acknowledged under oath a decade ago that he had sexual contact with Constand, but said it was consensual.

The case sets the stage for perhaps the biggest Hollywood celebrity trial of the mobile-all-the-time era and could send Cosby to prison in the twilight of his life and barrier-breaking career.

Case reopened in summer

The case represents an about-face by the Montgomery County district attorney's office, which declined to charge Cosby in 2005 when Constand first told police that the comic violated her by putting his hands down her pants at his mansion in suburban Philadelphia.

Prosecutors reopened the case over the summer as damaging testimony was unsealed in Constand's related civil lawsuit against Cosby and as dozens of other women came forward with similar accusations that made a mockery of his image as the wise and understanding Dr. Cliff Huxtable.

Andrea Constand 42 walks dogs in Toronto Dec 30 2015 Cosby accuser

Andrea Constand, who accuses Bill Cosby of sexually assaulting her, walks her dogs in Toronto, where she works as a massage therapist, on Dec. 30. (Mark Blinch/Reuters)

At that point, "reopening this case was not a question. Rather, reopening this case was our duty as law enforcement officers," Steele said. He urged any other alleged victims to come forward.

Constand, who is now 42, lives in the Toronto area and works as a massage therapist. Her attorney, Dolores Troiani, welcomed the charge.

"She feels that they believe her, and, to any victim, that is foremost in your mind: Are people going to believe me?" Troiani said.

The charge adds to the towering list of legal problems facing the actor, including defamation and sex-abuse lawsuits filed in Massachusetts, Los Angeles and Pennsylvania. But as for criminal charges, many of the alleged assaults date back decades, and the statute of limitations has expired in nearly every case.

In Los Angeles, Gloria Allred, the lawyer who has represented 29 women in civil lawsuits against Cosby, called the arraignment "the best Christmas present" her clients have ever received.

"In Pennsylvania, there is now a journey to justice in the felony case filed against Mr. Cosby. I am very happy that this day has come," she said.

"Unfortunately, for most of the women who alleged that they are victims of Mr. Cosby, it is too late for their allegations to be a subject of a criminal prosecution or a civil case."

TV fame

Cosby in 1965 became the first black actor to land a leading role in a network drama, I Spy, and he went on to earn three straight Emmys.

Cosby mugshot

The 78-year-old comedian will remain free on $1-million US bail. (Cheltenham Township Police )

Over the next three decades, the Philadelphia-born comic created TV's animated Fat Albert and the top-rated Cosby Show, the 1980s sitcom celebrated as groundbreaking television for its depiction of a warm and loving family headed by two black professionals — one a lawyer, the other a doctor.

He was a fatherly figure off camera as well, serving as a public moralist and public scold, urging young people to pull up their saggy pants and start acting responsibly.

Constand, who worked for the women's basketball team at Temple, where Cosby was a trustee and proud alumnus, said she was assaulted after going to his home in January 2004 for some career advice.