The law is controversial because if the victim was married during the crime, the suspect would remain guilty. However, because the victim was not married at the time, the suspect was not guilty.
The appellate judges admitted they did this reluctantly, but their hands were tied by a law many people didn't even know existed.
After seeing her boyfriend leave late at night, a man enters the bedroom of an unmarried woman and has sex with her while pretending to be her boyfriend.
According to a California appellate judges' ruling:
"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."
"This provision of the law where it only applies to a married woman as a victim really dates back to the mid 1800s, and while the legislatures had many opportunities to amend and revise the rape statute, for some unexplained reason they never got around to amending this particular statute," said ABC7 legal analyst Dana Cole.
The night began for the victim, identified as Jane Doe, at a party drinking several beers. She left the party with her boyfriend, Victor, grabbed some fast food, and headed home where friends joined them.
According to court documents, Jane invited her boyfriend to spend the night, but since he didn't have a condom, they decided against it and she fell asleep. Victor then left the room to go home.
Prosecutors say Jane then woke up to the sensation of having sex. When the light coming through a crack in the bedroom illuminated the face of the person having sex with her, she realized it was not Victor and tried to push him away.
Despite the struggle, the defendant, Julio Morales, continued and eventually left the room after Jane's cries.
Morales later told police "she probably thought I was her boyfriend."
The appellate judges said the jury that convicted Morales may have done so based on bad information from prosecutors.
"The law really requires the person be someone who impersonates her husband. And that was not the specific fact of this particular case," Cole said.
"An impersonation of anyone to rape should be a felony," said Patti Giggans, executive director of Peace Over Violence.
Giggans says she's determined to now work with Sacramento lawmakers on closing this loophole.
"I think there is now a heightened interest to take a look at something like this so I have a feeling we will be able to make a difference on this law," she said.
Morales has already served three years behind bars for his original conviction. The Los Angeles District Attorney's Office says it is looking into the possibility of re-trying the case.