This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

A 24-year-old Norwalk man convicted of raping a sleeping woman was sentenced Thursday to three years in state prison in a case that changed the law in California.

File photo (Credit: Getty Images)

In addition to prison, Julio Morales must also register as a sex offender based on his March 21 conviction, according to the Los Angeles County District Attorney’s Office.

Prosecutor alleged that on the morning of  Feb. 21, 2009, the victim was sleeping in her room with her boyfriend while several other people, including Morales, were partying in the living room.

At some point, the boyfriend left the bedroom and Morales got in bed with the victim and began having sex with her, prosecutors said.

Once the woman realized Morales was not her boyfriend, she began screaming.

Morales fled and was found by police hiding in some bushes about a mile away, the release stated.

In December 2010, Morales was tried and convicted of rape.

During the trial, Morales testified that the victim was awake and believed he was her boyfriend, the release stated.

The prosecutor argued that even if Morales was telling the truth, he still committed rape by pretending to be her boyfriend.

However, the conviction was overturned on appeal based on a 1872 law that only protected married women who were tricked into having sex with someone other than their spouse, the release stated.

As a result of public outcry over the ruling, the law was changed in September 2013 to protect unmarried women as well, according to the release.

In March, Morales was tried and convicted under the new law.