The jury in the trial of a 29-year-old who claimed he was asleep when he had sex with a friend has failed to agree on a verdict on a charge of rape.

After more than eight hours of deliberation and a four-week trial, the jury foreman told Mr Justice Patrick McCarthy they were "fairly far apart" and would not be able to reach a majority verdict.

The woman told the trial she was fully clothed while sharing a bed with the man after a night out in September 2008.

In the early hours of the morning, she woke up to find him having sex with her.

She said there was a conversation about contraception and the morning-after pill and she then left the apartment in a distressed state.

The pair, who had been friends for some time, met three days later to discuss what had happened.

It was agreed that the man would seek help for his behaviour. He was referred to a sleep clinic in Scotland.

However, the woman later made a complaint to gardaí and the man was charged with rape.

Two doctors who specialise in sleep disorders gave evidence during the trial.

They said the man was a parasomniac who was capable of carrying out involuntary sexual acts in his sleep, known as sexomnia.

The court also heard he had a history of sleep-walking and other behaviour while asleep.

A number of friends and a girlfriend gave evidence and said he had previously behaved in a sexual manner towards them while he was asleep.

Counsel for the defence Hugh Hartnett said experts with more than 30 years of experience had said people with such sleep disorders were capable of carrying out complex actions while asleep.

He said it was as a result of a "fracturing" between the upper and lower parts of the brain causing motor action to occur without intent.

However, a prosecution witness disagreed and said the events on the night demonstrated "goal orientated" conscious actions, which could not have occurred if he was asleep.

They pointed to evidence of the man pulling up a tight skirt the girl was wearing and moving her underwear to one side.

Prosecuting counsel Patrick McGrath said the defence of sexomnia was highly unusual and the jury should be sceptical about it and use common sense to decide what the most likely scenario was.

Mr McGrath said it was more likely he was drunk and opportunistic.

The defence had asked the jury to acquit him.

Mr Hartnett said there was every sympathy for the alleged victim and it should not have happened. However, he said the case was not about making it up to her.

He said the prosecution had not proven its case beyond all reasonable doubt.

The case will be mentioned before the court later this month when the prosecution will inform the court if a retrial is to take place.