A man accused of three counts of rape has been cleared by a jury because he was sleepwalking.
James Bilton, 22, told York Crown Court that he could not remember the alleged attack at his flat on Hope Street, York, and must have been sleepwalking.
Mr Bilton told police he had walked in his sleep since the age of 13.
A sleep expert said Mr Bilton was one of only 1-2.5% of the adult population who suffered from the condition. Mr Bilton had denied all three charges.
During the trial, the court heard the victim knew Mr Bilton and had slept in his bed after a night out, while Mr Bilton slept on the sofa.
Later, the 22-year-old, who can not be named, claimed she woke to find her trousers had been taken off and Mr Bilton was assaulting her.
She denied consenting to sex.
Mr Bilton said he could only remember waking up after sticking to the leather sofa and was "completely oblivious" to what had allegedly happened, the court heard.
But he said he had a history of sleepwalking which ran in the family.
Sleep expert Dr Ishaad Ebrahim said people who are sleepwalking can carry out actions that they do when awake.
And of the 1-2.5% of the adult population who suffer from the condition, 4% carry out sexual behaviour.
Mr Bilton's acquittal follows a similar case in Canada last month when Jan Luedecke, 33, was cleared of raping a woman after a judge ruled he was asleep at the time of the attack.
Mr Luedecke and the woman had gone to a party in 2003 where the woman fell asleep on the couch.
When she woke, she said she found him having sex with her.
He was charged with sexual assault but during his trial sleep experts testified that he suffered from sexsomnia - when a person has sex while they are still asleep.