It was an early October evening when 22-year-old Julie Bouvier and her friend Lynn decided to pop to their local shopping centre. Julie had forgotten Lynn's birthday, so wanted to take her out for a coffee. And Lynn had just had a baby and wanted to pick up some nappies. They parked and were walking towards the door of the store when Bouvier noticed a man behaving strangely.

"I saw him by the door, looking at me," she says. "As we were walking in, I turned back to have a second look and suddenly he was running towards me, yelling and cursing. He had wild, long hair and eyes so disturbed that I'll never forget them."

The man, who turned out to be a local called Sean Clifton, had just heard voices in his head. Over and over they told him to seek out the "prettiest girl in the mall" and go and stab her. On this particular Thursday night in 1999, that girl happened to be Bouvier.

At first she thought she had been punched, but then she saw the blood. Clifton stabbed her six times, missing her heart by half an inch and her spine by even less.

"Once I realised that I had been stabbed," Bouvier says, "I dropped to the floor. I thought if I played dead, maybe he wouldn't hurt me any more, because even after he'd stabbed me, he was still rampaging. I remember thinking, 'Is that it? Am I going to see the white light now? Is this the end of my life?' "

And then, just as suddenly as it had all started, it stopped. According to bystander Deric Latour, Clifton composed himself and stood quietly observing the scene, as if he'd had nothing to do with it. "Then he walked right up to me and said in a very calm voice: 'Do you think the police are going to come?' It stunned me," Latour says.

Earlier that day, Clifton, who has a history of schizophrenia and obsessive compulsive disorder (OCD), knew something was going very wrong. He could feel he was losing his grip on reality. "I just couldn't settle down. I was a mess," he says. "I was like a snowball rolling down a hill. Things started gathering speed."

He went to the emergency ward of the local psychiatric hospital and asked for help. "But they didn't take me seriously. I asked if I could just sit down and have a cup of coffee and talk a little and get it off my chest. But they were all too busy to listen."

So Clifton left the hospital and went to the mall, where he shoplifted a knife from Walmart and waited for a suitable victim. "I was just absolutely taken over by the feeling that I had to stab someone," he says. "I felt cornered into doing a violent thing. I didn't hope to accomplish anything – I just wanted the urge to stab someone to go away. Normally I am the type of person who does everything possible to avoid confrontation of any kind."

Clifton says he can't remember much about the voices in his head, nor the actual stabbing itself. "It was only when I was in the back of the police car that things became a little clearer," he says. "I remember sitting there watching the ambulance drivers getting Julie ready to go to hospital. They were unfolding a blanket to put on her. I did wish that they would hurry up a bit."

Julie Bouvier: ‘I know that he is so wanting to apologise in person to me. There may come a day, but at this point I’m still struggling with that’ PR

It was the sort of attack that nightmares are made of. Totally random, and of the kind that fleetingly cross your mind when you stand too near the edge of a train platform. But in many ways Clifton's very public explosion was a long time coming. His mother was mentally ill and he thinks he inherited it from her. But there were other factors, too. Growing up in the town of Cornwall in Ontario, Canada, Clifton was one of four boys. His brothers are 12, 13 and 14 years older than he is. "It was like having four fathers," he says. "When my marks at school were poor, I heard it from at least one or two of them. I felt very picked on."

Clifton's parents split up when he was six years old, and for some reason he stayed with his mother while his brothers went to live with their dad. His mum moved around a lot. "It seemed like every year we moved to a different apartment," he says. And because of the endless changes of school, he fell behind. "To use the baseball analogy, I could neither run, hit nor field."

Clifton also had a particularly tricky time with girls which, he says, goes some way to explaining why his victim had to be a female. "Girls were always a little more outspoken about how everybody hated me," he says. "I was picked on by girls and beaten up by girls. I've certainly had a rocky time with them."

He first started wondering about his sanity when he was about 14. By the time he was in his late teens, he had embraced his oddball role. "I was the town clown. I was the funny guy everybody kept an eye out for when they went out."

He went for intermittent counselling, and whenever he felt unstable would take himself off to the local outpatient psychiatric clinic. Sometimes, when he felt really bad, he thought about suicide. "There was a bridge in Cornwall that occasionally people jumped off. I would make a trip up there once in a while and I'd look down and just know I couldn't do it. I realised I had better just get used to my situation."

Perhaps unsurprisingly, in the court case that followed the stabbing, Clifton was deemed to be not criminally responsible. Instead of prison, he was sent to the forensic psychiatric facility at Brockville. Here, whether the patient has committed multiple murders or just shoplifted, the primary goal is to get them better and back into the community.

Bouvier, meanwhile, was slowly trying to pick up the pieces of her life. She went through two rounds of surgery, a collapsed lung and months of sleeping upright in a chair due to the pain. She got married the summer after the attack, as previously planned, and tried to put out of her mind a lingering fear that she might never be able to have children. People told her time and time again that she had just been in the wrong place at the wrong time, but it was little consolation.

"As much as I knew that was the truth, I still had a lot of questions," she says. "Why me? What made him lash out? I just couldn't understand it. But when he ended up going to Brockville, I felt safe. I thought he was going to be there for a very, very long time. I guess I never thought of what was going to happen later."

Doctors at Brockville say Clifton was one of the sickest patients they had ever seen. His OCD had taken such a grip that rituals and repetitive behaviour had completely taken over his life. He couldn't, for example, walk down the street until each step forward felt exactly right. So he would stand, repeatedly trying to put one foot in front of the other. Some days he would be there doing that same motion from dawn until dusk. It scared people and got him into trouble. He was thrown out of a motel where he was staying for doing it in the car park. He was just trying to get to the bus stop.

Clifton also had a problem with cutlery. He had to pick it up and put it down endlessly, until he felt he was holding it in the right way. Usually it was easier not to eat. He did that once and his eldest brother found him lying utterly dehydrated in a urine-soaked bed after a week without food or water. Similarly, he had an obsession with the second hand on a clock. He would have to watch it going round and round until it got to the particular point where he felt OK to break off. "I had to do these things because I had sensations of fear," he says. "If I didn't do them, I was sure a disaster would happen or something would happen to my family. I was afraid of a few different scenarios at the same time."

At Brockville, Clifton proved to be a model patient. He took everything they gave him – something for psychosis, something for depression, something for epilepsy and something for high blood pressure. They also gave him electro-convulsive therapy which, he says, he didn't really want. Initially, he was almost bedridden, but after about eight months he was deemed well enough to move off the high-security ward.

"After that I was moved to the minimum-security ward and then progressed to winning privileges to go out into the community accompanied by a nurse," Clifton says. "From there, it was only a matter of time before they moved me to a group home and then to a shared house and finally to my own apartment. It was a long haul. They told me there were people who had killed their children and who had been out in two or three years. It took me eight."

Although Clifton was banned from coming within 250km of Bouvier, when she heard he was out, she was terrified. "All the fear came back," says Bouvier, who by now had three children. "I just never knew if he would come back for me. I felt maybe he held a grudge or maybe he was angry that I got him sent away. I also knew that if he stopped taking his medication, he would regress in less than two weeks."

As Clifton's health continued to improve, he found the strength to do something he had always wanted. With the help of one of his nurses, he composed a letter to Bouvier in which he explained his illness and said how desperately sorry he was for what he had done. "As time went on, it became clearer what I had done to her," he says. "Even now, I regret it a little more each day."

For Bouvier, the letter changed everything. "Suddenly I was able to understand why he did it," she says. "Knowing that he was sick and that it was nothing personal was really important to me. I had no idea that he had all these OCD rituals. Just hearing what he had to go through on a daily basis was awful. It helped me find closure and it also helped me to forgive him. If I have any anger, it is that the system failed him that day."

Not long after Clifton had been released back into the community, Bouvier was approached by Emmy award-winning documentary director John Kastner to be in a film he was making. Kastner had gained unprecedented access to Brockville and was in the process of documenting Clifton's progress. At first Bouvier was unsure, but then she agreed to give her side of the story.

Filming took place over the course of almost two years, and although Bouvier and Clifton never came face to face, the process drew them together. They attended separate screenings, and for Bouvier being able to witness her attacker explaining his actions on celluloid has been a big help. For someone so deeply mentally ill, Clifton comes across in the film as highly self-aware and lucid. You can't help but feel sympathy. Bouvier, meanwhile, comes across as gentle and forgiving. At the end of Kastner's documentary, there is a scene where Bouvier's parents finally agree to meet Clifton and shake hands with him. It's a neat way to finish the film, but slightly overlooks the fact that there's still a delicate balancing act going on. Bouvier may have forgiven Clifton, but she still doesn't want to meet him. "I know that he is so wanting to apologise in person to me," she says. "There may come a day, but at this point I'm still struggling with that. I think it's probably more for him, and I want to do what's best for me as well."

Meanwhile, Clifton is pushing towards the final step in his rehabilitation, which is an absolute discharge – in other words, total freedom. He has some way to go yet, but if he gets there, there would be nothing – no law, no doctor, no nurse – in place to ensure he takes his medication. Bouvier says that Clifton has written her another letter, this one promising that he will continue to take his medication for the rest of his life. "But that doesn't stand up in a court of law," she says. "I think it's important to remember that Sean has committed a horrible crime and, who knows, maybe next year he might have an absolute discharge and he won't be forced to take his medication. That is one thing that's really so important to me – that there is something out there to protect me and protect society as well."

Clifton doesn't seem fully to appreciate her fear. "I know she is afraid and I do understand," he says, "but I think her fear of me is irrational. I just picked her out at random. I didn't single her out before I saw her that afternoon."

I ask if he can say for sure that he will never do something like this again. "It's been a long time since I've been in my right mind," he says. "I think I'm getting back there now. But I have to be vigilant, I have to keep an eye on myself. I was very surprised by my own capacity for violence. I don't like to give in to fatalism, but I never thought I'd stab somebody before I actually did it."

• John Kastner's NCR: Not Criminally Responsible is showing at Sheffield Doc/Fest on 12 and 13 June.