Sture Bergwall resides in a psychiatric hospital for the criminally insane three hours' drive north of Stockholm. A high wire fence circles the building. CCTV cameras track the movements of the outside world. The narrow windows – some of them barred – are smudged with dirt and thick with double-glazed glass. In order to visit, you must enter through a succession of automatically locking doors and walk through an airport-style security gate. You must leave your mobile phone in a specially provided locker and hand over your passport in return for an ID tag and a panic alarm. Two members of staff, wearing plastic clogs that squeak across the linoleum, escort you through the corridors.

In the visitors' room, Bergwall sits straight-backed on a small red chair, dim light glinting off rectangular-framed spectacles, his feet planted slightly apart in grey socks and Velcro-strapped sandals. He has been a patient in Säter hospital since 1991 and although he is 62, the flesh on his hands is still pink and unworn, the result, one imagines, of a lack of exposure to sunlight. His hair – what is left of it – is white.

Occasionally, he leans forward to take a pouch of chewing tobacco from a blue tin on the low table in front of him which he slips underneath his top lip. He smiles more than you might expect, each time displaying a line of small, yellow teeth pushed back like a fence falling in on itself. When he laughs, his shoulders shudder gently in his blue sweatshirt. The overall impression is that of a kindly, slightly shy older man who is eager to please. Does he believe he is criminally insane? Bergwall looks at me, smiles, and then shakes his head. "No." What will he do if he ever gets out of here? "I'll just walk straight ahead and keep going."

Until relatively recently, Sture Bergwall was Sweden's most notorious serial killer. He had confessed to more than 30 murders and been convicted of eight. He called himself Thomas Quick. Assuming this sinister alter ego, he claimed during a succession of therapy sessions at Säter over the years that he had maimed, raped and eaten the remains of his victims, the youngest of whom was a nine-year-old girl whose body has never been found.

Gry Storvik, 23. Murdered in Oslo, 1985. Quick was convicted on confession, with no supporting forensic evidence; indeed, semen from her body did not match Quick’s DNA. Charges were waived this September

During the 1990s, Thomas Quick confessed to one unsolved murder after another, becoming, in the words of the father of one of his alleged victims, "a ghost who ran through Scandinavia killing more than 30 people". The sadistic murderer was a media sensation and his bespectacled face stared out from front pages and television screens. The newspapers called him "the cannibal". Thomas Quick became Sweden's very own Hannibal Lecter.

But then, in 2001, he stopped co-operating with the police. He withdrew from public view and changed his name back to the one he was born with. In 2008, Hannes Råstam, one of Sweden's most respected documentary-makers, became intrigued. He visited the former Thomas Quick, now known as Sture Bergwall, at Säter, trawled through the 50,000 pages of court documents, therapy notes and police interrogations and came to the startling conclusion that there was not a single shred of technical evidence for any of Bergwall's convictions. There were no DNA traces, no murder weapons, no eyewitnesses – nothing apart from his confessions, many of which had been given when he was under the influence of narcotic-strength drugs. Confronted with Råstam's discoveries, Bergwall admitted the unthinkable. He said he had fabricated the entire story.

The book recounting this extraordinary tale has just been posthumously published in Sweden – Råstam died aged 56 from cancer of the pancreas and the liver in January, the day after the manuscript was finished. In Thomas Quick: The Making of a Serial Killer, Råstam unpicks in painstaking detail the way in which the deeply troubled Quick was able to gain key information surrounding each case from psychiatrists, police officers and lawyers, before cobbling together the rambling and confused testimonies into a coherent narrative that could stand up in court.

Jenny Küttim, who was Råstam's researcher for three years on the story, was appalled by what they found. "The worst part is that because of people not doing their job, there are a lot of killers out there who never got caught or faced justice," she says.

In a country that has become synonymous with the dogged fictional detectives of Henning Mankell and Scandinavian TV drama, the book has prompted a public outcry and a judicial scandal. Bergwall has now been acquitted of five of the eight murders. Two outstanding cases – one for the murder of 15-year-old Charles Zelmanovits, one for the double killing of a Dutch couple on a camping trip – have been submitted for review. Bergwall's lawyer, Thomas Olsson, expects the verdicts will be quashed and he will then start fighting for his client's release from the psychiatric hospital in which he has been incarcerated for more than 20 years. According to Olsson, the strange case of the serial killer who never was "raises serious questions about the entire legal system".

But why would a man confess to such sadistic and violent crimes if he was truly innocent? Back in the visitors' room at Säter, Sture Bergwall tries to explain. "It was about belonging to something," he says, speaking in Swedish through a translator. His voice is quiet but insistent and his thoughts are intelligently expressed. I am the first British journalist he has ever spoken to. But it wasn't too hard to get hold of him – although he entered Säter before the widespread use of the internet or mobile phones, he now has his own Twitter account.

"I was a very lonely person when it all started," he continues. "I was in a place with violent criminals and I noticed that the worse or more violent or serious the crime, the more interest someone got from the psychiatric personnel. I also wanted to belong to that group, to be an interesting person in here."

Bergwall had always wanted to meld in. He was a teenage misfit. He grew up in a small town in rural Sweden, one of seven siblings raised according to strict Pentecostal beliefs. He describes himself as a "creative and ambitious" child, interested in theatre and writing. At 14, he realised he was gay. Ashamed by his sexuality, he hid it from his deeply religious parents. He started experimenting with drugs – amphetamine was his favourite – and, at the age of 19, was accused of molesting adolescent boys. Later, he tried to stab a former lover. In 1990, he robbed a local bank dressed in a Santa Claus outfit to feed his addiction. The clerk recognised him. He was incarcerated in Säter hospital for psychiatric treatment. Not a stable individual, then, but not a serial killer – at least, not yet.

As a young man, Bergwall had always hankered after being taken seriously and treated as an intelligent person. For a while, he wanted to be a doctor and read up on psychoanalysis. In Säter, he began to realise he could use this knowledge to get the attention and acceptance he craved. "What would you say," he asked his therapist one day in 1992, "if I had done something really bad?"

"That created a reaction, an interest," Bergwall says now. "I said: 'Maybe I murdered someone' and once I'd said that, there was no going back."

Charles Zelmanovits, 15. Disappeared from northern town of Piteå in 1976. His remains were found in 1993. Quick was sentenced in 1994 via a confession, with no forensic evidence

The first "murder" Thomas Quick confessed to was that of Johan Asplund, the victim of one of the greatest criminal mysteries in Swedish history. Johan was an 11-year-old boy who went to school one day in November 1980 and disappeared. His body has never been found. During a series of therapy sessions and, later, in police interviews, Quick said he had picked Johan up outside school and lured him into his car before taking him to a wooded area and raping him. Quick claimed he had panicked and strangled the boy, subsequently burying Johan's dismembered body parts so that no one could find them.

But despite forensic technicians searching the locations described by Quick, no remains were ever found. In fact, it took nine years for prosecutors to cobble together a case against Quick – he was finally convicted of Johan's murder in 2001. By that time, Quick had already been found guilty of seven other killings. Yet, oddly for a serial killer, there was no obvious modus operandi: Quick killed children and adults, he raped men and women, he used an array of weapons and committed murders in various parts of Sweden and Norway.

In 1996, he confessed to the murder of nine-year-old Therese Johannessen in Norway eight years previously. Quick initially said the girl was blonde and lived in a rural village, despite the fact that she had dark brown hair and lived in a tower block in a heavily urbanised area.

"He got zero right," Bergwall's lawyer, Thomas Olsson, tells me later in the car on the way back from Säter. "He described a totally different situation in all aspects but instead of accepting that, they went on with 15 new interviews."

Olsson, who was brought in to represent Sture Bergwall after he retracted his confessions, has a reputation for taking on difficult cases. With his swept-back hair, bristled face and chain-smoking habit, he is precisely the kind of person one can imagine playing the role of a campaigning Scandinavian lawyer in a film. He drives too fast in a car strewn with empty coffee cups. Although he isn't religious, his wife has insisted he hang a string of rosary beads from his rear-view mirror as a reminder to slow down.

Does Olsson believe Bergwall is dangerous? He snorts. "No! Not at all." Does he like him? "I don't like people too much in general," he says after a pause. "But, of course, if you spend so much time with a client, you always see the person behind the headlines. It all starts with a little boy under a Christmas tree, playing with toys and it ends up very tragic. Somewhere along the line, everyone is a victim."

After "confessing" to the murder of Therese Johannessen, Quick was driven to Norway. The TV cameras followed his every move. He was rapidly becoming one of the most famous men in Scandinavia and revelled in the attention. When Quick claimed he had thrown Therese's body parts in a nearby lake, the Norwegian authorities spent seven weeks' draining it. They found nothing. When a 0.5mm "bone fragment" was discovered in adjoining woodland, it later turned out to be a charred piece of wood. Despite this, Quick was convicted.

Even more curiously, he appeared to have a cast-iron alibi for some of his crimes. Although he confessed to killing a teenage boy in 1964 at the age of 14, it turned out that several witnesses could remember seeing him at holy communion with his non-identical twin sister, some 250 miles away. In fact, there was a photograph showing him there. When he claimed responsibility for the killing of a 23-year-old woman in Norway in 1985, he said he had sex with her despite his stated sexual preference for men. The police had found traces of sperm but a subsequent DNA analysis ruled out the possibility that it belonged to Thomas Quick. And yet the courts once again found him guilty "beyond all reasonable doubt".

Yenon Levi, 24. An Israeli tourist, killed while trekking in Dalarna in 1988. Quick was sentenced in 1997, without forensic evidence but on statements that matched facts not disclosed publicly. Charges were waived in 2010

Defenders of the verdicts pointed out that, in interview, Quick had revealed telling pieces of information from each of the crimes that only the killer would know. Still today, there are those who robustly defend the police investigations, including supreme court judge Göran Lambertz, who conducted a week-long review of the Quick case in 2006 in his previous role as attorney general and found it all to be above board.

"There is no DNA nor fingerprints and [the evidence] is not as strong as it could be," says Lambertz when we meet. "What there is is everything he [Quick] said back then that sort of fits in. He gave a lot of facts about two murders in particular [Johannessen and Zelmanovits] that fit so well with what actually happened and what kind of children these two were."

But according to Bergwall, a lot of the information was already in the public domain: early on in his confessional spree, he still had regular leaves of absence from the hospital.

"I'd go to the Royal Library in Stockholm on day release and read up on old cases on the newspaper microfiches," he explains. Bergwall noted down the telling details in contemporaneous reports – the positioning of the body, the specifics of the landscape, the victim's clothing – which he would later "reveal" in therapy as Thomas Quick. His therapist (who saw him for a minimum of three 90-minute sessions each week) would praise him for his bravery in digging deep into his remembered past. The police would be thrilled at the emergence of a credible suspect for a previously unsolvable crime. On at least two occasions, Quick was flown by private jet to take part in reconstructions at murder sites. All the time, Quick was basking in the reflected glory, like a praised child.

"I didn't need to do much to tell the stories," he says. "Usually a single newspaper article would be enough. The rest of the information always came during the interrogations from the police, therapists or different people on the investigations team. I knew I just had to listen to pay attention."

In all of his therapy sessions and the ensuing police reconstructions, Bergwall was heavily drugged on a cocktail of benzodiazepines. Medical records show he was being given tablets every couple of hours – often up to 20mg of diazepam, enough to knock some people out cold. A high dosage given to those with poor impulse control can lead to a release of inhibitions and could explain why Bergwall was able to invent such a grotesque litany of cannibalism, rape and murder. At the time, he remembers being fascinated by depictions of fictional serial killers – astonishingly, he was able to borrow a copy of Bret Easton Ellis's American Psycho from the hospital library.

"The drugs were very important," says Bergwall. "I had free access to them and I relied on them to get me into a condition where I could tell stories and make them up."

What effect did the drugs have on him?

"A lot happened inside of me. I'd get high, I'd get a kick and then I'd have lots of fantasies. My imagination would run wild. In one sense, they gave me a lot of creativity. It was like a vicious circle. The more I told, the more attention I got from the therapists and the police and the memory experts and that meant I also got more drugs."

There was a clique of people around Quick, variously described by those I talk to as being akin to "a cult", "a travelling circus" and "a religious sect that did not welcome dissenting beliefs". The same police officer, therapist, prosecuting and defence lawyer dealt with each of his confessions through the years. Even the same sniffer dog, Zampo, was used to trawl each "murder" site.

"During the course of the investigation, Quick mentioned at least 24 different places in Sweden and Norway where he had committed murders, handled dead bodies or left body parts," says Leyla Belle Drake, who was Hannes Råstam's literary agent. "Zampo marked for human remains 45 times at those 24 locations. Not a single trace of blood or body parts was ever found. The dog is just as bad as the rest of them."

Trine Jensen, 17. Found dead outside Oslo in 1981. Quick was sentenced in 2000. Charges were waived in September this year

The theory this select group propounded was that the patient had repressed extremely traumatic memories, which resurfaced in the form of dream-like sequences that could often be littered with inconsistencies. It was only through repeated therapy sessions with trusted confidants and the administration of calming drugs that the real narrative could emerge.

For Jenny Küttim, this is one of the most scandalous elements of the whole strange affair.

"He was a mental patient in a mental hospital in Säter," says Küttim, her restrained anger almost tangible. "He was the only one who didn't have a job. The other people around him were the ones who were meant to be saying 'No, we don't believe you.' In that sense, you cannot blame Sture Bergwall, because a lot of people around him should have said no. At the same time, he's also to blame because he's hurt a lot of people by telling these stories."

Prime among those were the victims' loved ones, who had their grief exposed in public, their hopes raised by a fantasist and then dashed by professional incompetence. Björn Asplund is one of them: the father of the missing 11-year-old boy who was the subject of Quick's first confession. Asplund, 65, lives on a houseboat called Viking, tied to a permanent mooring on Lake Mälaren in central Stockholm. Inside, a coffee pot boils on the stove in a galley kitchen and the boat rocks gently from side to side with each exhalation of the tide. On the wall above the dining table where we sit hangs a black and white photograph of Johan: a smiling boy with a pudding-bowl haircut.

"He was very popular in school, just a great kid," says Asplund. "His dream was to become a farmer." Asplund and his ex-wife, Anna-Clara (the couple divorced when Johan was three years old), were told in 1993 that a mental patient they had never met had confessed to the abduction and murder of their son. From the beginning, neither of them believed it.

"Not for many reasons," says Asplund, who works for a mental health charity. "In almost all cases where the child is the victim, it is someone who has a close relation to the child who is the perpetrator."

Thomas Quick was unknown to them. In fact, the Asplunds were convinced they knew who did it: an ex-partner of Anna-Clara who wanted to seek revenge for the break-up of their relationship. There was enough circumstantial evidence against this suspect for the Asplunds to pursue a private prosecution against him. The ex-partner was sentenced to two years in prison for kidnapping but freed on appeal a year later. Björn Asplund, however, remains convinced of this man's guilt.

"It made me angry when Thomas Quick confessed because, from that point, I realised that the whole case was closed against the ex-partner," he says. That it then took seven long years for Quick to frame a coherent sequence of events only confirmed the couple's suspicions: "For every sober person in this country, it must have been obvious that this guy was not trustworthy."

During the investigation, Asplund believes it was obvious that Quick was getting his information from the police. "We found out that everything we would tell them would come out a few weeks later in his therapy sessions," he says.

As an example, he points to the fact that Johan had a distinguishing birthmark on his right buttock that only his parents knew about. In early interviews, Quick claimed only that Johan had some vague marks or scars on the front of his stomach, possibly from surgery. The police asked the Asplunds if Johan had any such scars. For a while, they refused to be specific because of their suspicions that the information would make its way back to Quick.

"Then they threatened to take Anna-Clara to court for protecting a murderer," Asplund recalls. "So she drew a picture of the birthmark."

Shortly afterwards, Quick "remembered" the mark in therapy. Indeed, for every murder he confessed to, Quick was subjected to an average of 10-15 police interviews. When he claimed he had killed an Israeli backpacker, Yenon Levi, in the Dalarna woods in 1988, Quick was asked repeatedly what murder weapon he had used. In interviews, he mentioned a camping axe, a spade and a carjack among other items before finally alighting on the "right" object: a wooden club. In court, Quick's indecisiveness was glossed over: it was stated simply that he had correctly identified the murder weapon.

For the victims' families, the prolonged nature of each investigation was extremely distressing. Asplund, whose life had already been shattered once by his son's disappearance, was forced yet again to dredge up painful memories and then to listen to Quick's horrific testimony in court. Quick claimed he ate Johan's fingers; that he cut off the child's head and kicked it like a football.

Asplund looks away, takes a drag of his roll-up cigarette. "Sitting there listening to that, even if you knew it wasn't true …" he says. "It was an awful situation."

Janni and Marinus Stegehuis, 34, 39. Dutch couple who were found stabbed to death in a tent in northern Sweden in 1984. Quick gave police facts that again had not been made public

With his son dead and the killer still at large, does Asplund feel betrayed? He answers with another question: "What can you do about it? I don't think being angry will help me. Whatever happens, you have to focus on the future and go forward. You have to make the decision about whether you want to live or not. And if the choice is to live, you have to live your full life. You can't spend it sitting in the corner, thinking about what happened."

Back in Säter hospital, I ask Sture whether he thought about the impact his confessions might be having on the victims' families.

"Yes. I did think of them, but I didn't. In a way, I was ruthless, but that was also one of the effects of the benzo [benzodiazepine]. It meant I could ignore any compassion."

Did he know he was lying? "This is the most difficult part to explain. There was an awareness that it was lies. At the same time, I was living in this role as Thomas Quick and in this role, I could forget that awareness. During the Thomas Quick years, I tried to hang myself. I banged my head against the wall until it bled. In the nights, I would wake up screaming 'No!' [this was noted in the hospital's medical records]. In the middle of the nights, there was an awareness that it was all make believe and then when I woke up, I got a dose of benzo and I could forget it and push it aside."

In 2001, a new clinical director at Säter reviewed Quick's medical records. He was shocked to discover the dosage and Quick's supply of drugs quickly dwindled. Once he stopped taking them, he stopped confessing. Instead, he announced to journalists that he would no longer co-operate with the police and withdrew from public view. He then kept his silence for seven years until Hannes Råstam tracked him down.

"Hannes was a very intense person with an ability to really listen to other people and also to share," says Bergwall, for the first time showing some small hint of emotion. "I remember the third time we met, Hannes had seen the videotapes of the police reconstructions and he said: 'I can see you're high on drugs.' It was the first time that I remember thinking: 'Something's going to happen.' I felt: 'Yes! Something's going to change' and I was ready to confess.

"It was so liberating to finally tell the truth and to know that I didn't have anything to fear since it was the truth."

Not everyone believes Sture Bergwall is the victim of one of the grossest miscarriages of justice in recent times. There are those who point out that he has a track record of lying convincingly and manipulating people. I am aware, throughout my conversation with him, that Bergwall is skilled at being able to mirror back what someone most wants to hear.

Judge Göran Lambertz cautions against "rushing to conclusions". He believes that in the pile of false details Bergwall gave to police, there might still be some elements of truth. This position has made him deeply unpopular in certain parts of Swedish society, especially with those – like Thomas Olsson and Jenny Küttim – who are campaigning for Bergwall's release.

"A lot of people have made their careers on the Thomas Quick case," says Küttim. "So today they have a lot to lose."

Lambertz is dismissive when I put this to him. "Oh yes, I'm a hated man," he says blithely. "I think Sture Bergwall is fooling us now, that's what I think. I don't think he's harmless. He may be a nice old man, I don't know, but the psychiatrists up there say he is still dangerous."

And what if Bergwall is acquitted of all these murders by the courts? Will Lambertz still be sceptical? Will he apologise for conducting a review six years ago into the Quick case which found no fault with the police investigation?

"It could be right [to acquit him], it could be all wrong. It could be somewhere in the middle, I don't know. But if you ask me what I think, I would think it is more wrong than right."

In Säter, our time is coming to a close. Bergwall rises and waits patiently to be taken back to his ward upstairs by the two members of staff. When he has gone, what strikes me most about him is his absence of personality. He leaves no strong impression. It is perfectly possible, of course, that after 21 years of incarceration and drug addiction, he no longer has much of an idea of who he is.

Outside, standing in the cold grey afternoon and looking up to the first floor of the hospital building, I see Bergwall at the window. He smiles, gives a small wave and then the serial killer who never was is led away. All that is left behind is the light reflected on the glass and the shadows where, a moment ago, he stood.