Basing its decision on a law from 1872, an appeals court in California ruled that a man convicted of rape by a trial court was not guilty of the crime because the woman he allegedly raped wasn't married.

Julio Morales was sentenced to three years in prison for entering a woman's bedroom and having sex with her while she slept.

According to the victim, she didn't initially refuse because she believed Morales was her boyfriend, who was in the room when she fell asleep.

"A man enters the dark bedroom of an unmarried woman after seeing her boyfriend leave late at night, and has sexual intercourse with the woman while pretending to be the boyfriend," wrote the 2nd District Court of Appeal in its decision. "Has the man committed rape? Because of historical anomalies in the law and the statutory definition of rape, the answer is no, even though, if the woman had been married and the man had impersonated her husband, the answer would be yes."

According to Judge Thomas L. Willhite Jr., because it was unclear whether the jury convicted Morales over the deceit — which isn't considered rape under California law — or over engaging in sex with a sleeping person — which is considered rape — the entire case must be retried.

The three-judge panel noted in its decision that the ruling was made "reluctantly," and urged the legislature to amend the code.

[photo via Shutterstock]