The Montgomery County district attorney in Pennsylvania charged embattled comedian Bill Cosby with three counts of aggravated indecent assault, a second-degree felony, on Wednesday morning.

This is the first time criminal charges have been brought against Cosby, who has been accused of sexual assault by more than 40 women over the years. The comedian has denied all allegations and is currently involved in defamation lawsuits against some of the alleged victims.

If convicted of the second-degree felony, Cosby faces a maximum penalty of five to ten years in prison and a $25,000 fine, prosecutors said.

“Reopening this case was not a question,” Kevin Steele, the first assistant prosecutor, said at a news conference Wednesday. A previous district attorney refused to charge Cosby.

A judge ordered Cosby to turn over his passport and have no contact with the victim at an arraignment hearing on Wednesday afternoon. He was released after posting $100,000, 10% of his $1 million bail as required, the district attorney said.

The criminal charge stems from an investigation into an incident of alleged sexual assault that occurred at the comedian's home in Cheltenham, Pennsylvania, in 2004.

Toronto Public Library / Getty Images

Andrea Constand

Andrea Constand, the victim of the alleged assault, was an employee at Temple University between 2001 and 2004 where Cosby started college in 1961. He established a relationship with Constand through her work for the women’s basketball program at Temple, Steele said. She came to consider Cosby her "mentor and friend." She rejected two sexual advances that Cosby made at her before the alleged assault but continued to trust him and accept his invitations, according to the criminal complaint.

On the night of the alleged assault, Cosby invited Constand to his home in Cheltenham to talk about her future career plans. He told her they would be alone and asked to dress comfortably, the criminal complaint stated.

After Constand told Cosby that she felt "drained and emotionally-occupied" and was sleep-deprived, Cosby said he wanted her to relax. He then gave her three blue pills, saying they would make her feel good. He told her the pills were herbal and said, "Down them. Put 'em down. Put them in your mouth," the complaint stated. Constand told Cosby she trusted him and swallowed all three pills with water.

He then told her to taste wine that he offered her despite her protests that she hadn't eaten anything all day. In about 20-30 minutes after she took the pills and the wine, Constand told police that she experienced blurred vision after which Cosby told her to lie on his couch. Constand said she lost strength in her legs which felt "rubbery" and "like jelly" and that she was dizzy and nauseous.

From the complaint:

Cosby did not sit on the sofa with her, but instead positioned himself behind her. Despite her impaired physical and mental condition, the victim was aware that Cosby was fondling her breasts, put his hands into her pants, and penetrated her vagina with his fingers. Cosby also took the victim's right hand and placed it onto his erect penis. The victim told investigators that she did not consent to any of these acts, and was unable to move or speak during the assault. She described her condition as "frozen" and "paralyzed."

When Constand woke up early next morning she found that her sweater was bunched, her bra was undone and had moved above her breasts, the complaint said. She said that Cosby, who was in a robe, gave her a muffin, opened the front door and said "Alright." She left his house without saying anything, according to the complaint.

When Constand's mother confronted Cosby on the phone a year later — after her daughter revealed the assault to her — he admitted to the incident, apologized and offered to pay for her therapy, the complaint said.

Cosby told Cheltenham police that the sexual encounter was consensual and that he gave Constand Benadryl pills. When asked if he had had sex with her, Cosby responded, "Never asleep or awake."

Steele said there were a number of aspects in the case that were "undisputed," leading to the charge against Cosby. He said the charges filed today were a result of "new information that came to light in July 2015," referring to testimony from a related civil lawsuit that was unsealed this year. Investigators reinterviewed witnesses, examined testimony from the civil case, and gained information from Cosby's other alleged victims.

"The victim has indicated that she will be willing to cooperate with us going forward," Steele said.

In a statement to BuzzFeed News, Constand's attorney, Dolores Trioani, expressed appreciation to the D.A.'s office, detectives, and police "for the consideration and courtesy they have shown Andrea during this difficult time." Trioani said they had confidence in the authorities but could not comment further as it was a criminal case.

Cosby’s lawyer at the time of the assault, Walter M. Phillips Jr., told CNN the allegations were “utterly preposterous” and “plainly bizarre." Although Constand reported the alleged assault to Pennsylvania authorities, prosecutors refused to pursue charges against Cosby.

In March 2005, Constand filed a civil suit against Cosby charging him with battery and sexual assault. The lawsuit mentioned 13 Jane Does with similar stories, most of whom have gone public with their accusations since. Before any of them could testify, the suit was settled out of court with Constand for an undisclosed amount in 2006. There was no admission of guilt.

In Pennsylvania, the statute of limitations for aggravated indecent assault is 12 years, giving prosecutors until January 2016 to file charges.

Joe Cammarhea, the attorney who represents Joan Tarshis, one of Cosby's accusers, called the announcement “a positive step.”

“It undermines his contention, at least with respect to Andrea, that his encounter with her was consensual,” he told BuzzFeed News. “This is going to have a significant impact on the other cases pending against him.”

Tarshis was unable to comment because of the defamation countersuit Cosby filed against her and several other women earlier this month. Between October and November, a total of 10 women sued him for defamation.

On Nov. 19, 2014, the former Montgomery County district attorney, Bruce Castor, told the Associated Press that he stood by his decision not to charge Cosby because there wasn’t enough evidence to convict him.

On Oct. 26, 2015, Constand filed a defamation lawsuit against Castor seeking $150,000 in damages. The civil lawsuit said that Castor used her allegations against Cosby in his political campaign to get reelected, and accused him of attempting to “thwart the 2015 investigation” into Cosby. Castor could not immediately be reached for comment.

The lawsuit also accused Castor of defamation based on an Oct. 21, 2015, interview with the Associated Press, where Castor alleged that Constand had “enhanced her story” when she sued Cosby and described the alleged discrepancies as “troublesome for the good guys.”