A "decent and devoted" husband who strangled his wife while he dreamt she was a intruder has been cleared of murder after the Crown Prosecution Service accepted he had not been in control of his actions but was not a danger to anyone else.

Father-of-two Brian Thomas killed his wife, Christine, as he was in the throes of a nightmare about a "boy racer" who had broken into the camper van they were sleeping in. Members of the jury at Swansea crown court wept after they were ordered to formally acquit Thomas, who had suffered "night terrors" for about 50 years without ever being treated.

Experts said afterwards that about 2% of the population in the UK suffered from the condition, also known as pavor nocturnus. It was possible that many other similar attacks were carried out, though not with fatal consequences, and so went unreported.

Thomas, a retired steelworker from Neath in south Wales, will be advised to seek treatment for his condition. Friends and family said he was devastated by the loss of his beloved wife of almost 40 years. In court he was described as a "broken man" who might try to harm himself. Since he was a child Thomas had been prone to sleepwalking and other sleep disorders. At home he and his wife slept in separate bedrooms but shared a double bed when they went away in their campervan.

Thomas, 59, used to take tablets for depression but stopped taking them when he and his wife, 57, went away in their van because they made him impotent.

In July last year the couple went on one of their regular jaunts in their camper van. They parked up in a carpark in the seaside village of Aberporth, west Wales but were disturbed by "boy racers" performing wheelspins and handbrake turns at 11.30pm.

They drove to the carpark of the Ship Inn in the village where they settled down for the night. But later Thomas made a 999 call saying he had strangled his wife in his sleep.

He told the operator: "What have I done? I've been trying to wake her. I think I've killed my wife. Oh my God. I thought someone had broken in.

"I was fighting with those boys but it was Christine. I must have been dreaming or something. What have I done? What have I done? Can you send someone?"

At first police were sceptical but friends and relatives told detectives they were a loving couple. They enjoyed regular nights out, watched rugby together and had booked a Mediterranean cruise to celebrate their forthcoming 40th wedding anniversary. Tests carried out on Thomas, some while he spent 10 months in prison on remand, confirmed he suffered from night terrors.

At the start of the trial the prosecution said it was a "unique" case. It accepted Thomas should be found not guilty but initially called for a special verdict of not guilty due to insanity, which would have meant he could have been held in a secure psychiatric hospital. The law dictates that this is a verdict that cannot be determined by anyone other than a jury, which is why the case had to go to court.

But in the end the CPS decided to offer no more evidence and the jury returned a straightforward verdict of not guilty.

The judge, Mr Justice Nigel Davis, told Thomas: "You are a decent man and a devoted husband. I strongly suspect that you may well be feeling a sense of guilt. In the eyes of the law you bear no responsibility. You are discharged.

"All of us who have been in court and who listened to the 999 call know exactly what your feelings were when you found that your wife was dead."

Iwan Jenkins, the chief crown prosecutor for CPS Dyfed Powys, defended the handling of the case, saying: "This has been a unique case with a unique set of circumstances. We have a duty to keep cases under continuous review, and following expert evidence from a psychiatrist it was suggested no useful purpose would be served by Mr Thomas being detained and treated in a psychiatric hospital, which would be the consequence of a special verdict in this case."

The jury had been told that Thomas's sleep disorder meant he was in a state of "automatism" – his mind was not in control of his body. It is possible he had suffered particularly severe night terrors because he had come off his regular medication."

Members of his family cheered as the verdict was returned. Speaking outside the court, Thomas's brother, Raymond, said: "He's a gentle man and always has been. He's a good man. Christine and Brian loved each other." He said it was wrong that his brother had been held on remand.A neighbour from Neath, Anita Gore, 75, said: "There is nothing that he has to feel guilty about – it is just all so tragic."

Night terrors

As many as 10% of children in the UK suffer from pavor nocturnus. Most grow out of it but at least 2% of adults carry on having terrible, vivid dreams.

Chris Idzikowski of the London Sleep Centre was an expert witness in the Thomas case. He said it was known for people to attack partners while having a nightmare. Most cases went unreported because usually no lasting damage was caused and those involved were often embarrassed to discuss it with outsiders.

Both pavor nocturnus and other conditions such as REM sleep behaviour disorder, often a violent episode during the rapid eye movement stage of sleep, can be controlled with drugs.

In 2005 a man from Manchester, Jules Lowe, was found not guilty of murdering his father, Eddie, due to insanity while he was sleepwalking. He was sent to a psychiatric hospital.

In 1998 chef Dean Sokell was jailed for life after battering his wife Eleni to death in an attack at their home in Paignton, Devon, that began while he was asleep.

The 27-year-old admitted murder on the basis that he had woken up to find he was hitting his wife with a claw hammer – but then, while awake, carried on and finally stabbed her to silence the screams.

Another high-profile case turning on the concept of automatism was that of the guitarist Peter Buck of the band REM. He was acquitted of attacking BA staff on a transatlantic flight to London in 2002. The court accepted he had no recollection of the incident because he was suffering from non-insane automatism at the time, brought on by combining alcohol and a sleeping pill at the start of the flight.