A Swedish man who had sex with a woman while he was asleep has been acquitted of rape because he suffers from "sexsomnia", according to an appeal court ruling obtained by a news agency on Thursday.

The 26-year-old man did not have the intention to have sex, the Sundsvall appeal court in northern Sweden said, as it overruled the previous two-year prison sentence. The argument that the defendant "was in a state of sleepiness, unconscious of what was happening, does not seem absurd", the court said in its judgment.

The decision was mainly motivated by the intervention of a doctor specialising in sleep disorders, who said that the defendant could suffer from so-called sexsomnia, a state in which a person can have sex while they are asleep. The theory was corroborated by the man's previous partner.

According to psychiatrists specialising in sexsomnia, a condition that has not yet been widely researched or recognised, it is a sleeping disorder closely related to sleepwalking which includes sexual behaviour. Those affected by sexsomnia are completely unaware of their acts, specialists say. However, the affliction is likely to remain controversial among physicians and lawyers.