Jackie Malton and Graham Godden used to hate each other, although they had never met. That is to say that Detective Chief Inspector Malton of the Flying Squad, the thief-taking, go-getting, hard-drinking real-life role model for DCI Jane Tennison of the television series Prime Suspect used to hate all armed robbers. And Godden, once "Britain's most wanted robber", the "M25 Bandit" and a reckless heroin addict, used to hate all coppers. Now, as they sit together having afternoon tea in Wimbledon, they regard each other with admiration, affection, even love.

What has brought them together and what has happened to Malton since she left the police is as remarkable as any of the dramas in which her fictional alter ego was involved. This former cop is now spending as much time tackling criminals as she did in her days in the force, although in a very different way.

Jackie Malton was born in 1951, the daughter of an Associated Newspapers executive, and grew up in Lincolnshire and Leicestershire. As a 10-year-old, she was fascinated by history lessons about the period of the industrial revolution and, in particular, the prison reformer Elizabeth Fry.

"I was always drawn to what you might call the darkness and I would have loved to have been a psychologist or a probation officer," she says. "When I was a kid, my parents were called in by the headmaster at my school because I was such a tomboy and spent so much of my time playing with the boys that he was afraid that, as we all reached puberty, I would be abandoned. I was always on the edge, looking in. I was fascinated by why people did things and I loved watching them – it was almost voyeuristic. But I was an 11-plus failure and the nearest thing to what I was interested in was the police."

Malton joined the Leicestershire force at a time when female officers were still restricted to minor, "women-related" tasks, often dealing with prostitutes. In 1979, she moved to the Metropolitan Police and, as a detective, was involved in the investigations into the 1981 New Cross fire – in which 13 young black people died in mysterious circumstances and which became a major political issue – and the Brixton riots the same year.

The police was still a very macho world. "My experience was certainly affected by my sexuality. I was openly gay so they couldn't accuse me of sleeping my way through the ranks, as they did with other women who were promoted. I would be given sex toys as Christmas presents – enough to open a sex-goods shop! I'm not saying it was malicious, because the men were very different one-on-one, but there was a lot of playing to the crowd. It was a tough upbringing but I don't want to come across as a victim because that's not what I feel. Things have changed so much since then and it became easier the higher up you got. To have the Flying Squad on your CV meant that you did take armed robbers and no one could take that away from you."

A young Jackie Malton in her days with the Flying Squad: “After an arrest you had to go for a drink. You couldn’t go home because your head was buzzing”:

It was in the Flying Squad that Malton was first to come across those members of the underworld's aristocracy. "I always believed that armed robbers were outside the normal criminals I dealt with, in that they didn't have any excuse – they were just driven by greed. It was about money and grandiosity and threatening people with firearms. Not once did I feel the empathy for them which I felt for all other criminals. They lived in huge, tasteless houses in Kent and Essex and it was about ego and status. It was cops and robbers, us against them. I found them quite hateful."

Her job involved nicking those very characters. "The guv'nor would say 'Go! Go!' and, in that split second, you took them across the pavement. The adrenaline! I remember one time I got out of the Flying Squad car while it was still in motion. There were three robbers and I already had mine in my sights. Looking back, I was mad. I wasn't armed. I just ran, picked the one I was going to arrest and got him. You believe you're invincible."

Successful investigations and arrests usually concluded with a big drink-up in the office. "You had to go for a drink. You couldn't go home because your head was buzzing." At her lowest, it was whisky in a morning cup of tea. Alcohol became Malton's anaesthetic and repair kit, as it did for the character played so memorably by Helen Mirren in Lynda La Plante's dramas.

It is 19 years since Malton joined Alcoholics Anonymous (AA) and had her last gin and tonic. It is nearly 15 years since she left the police but she is dealing with as many criminals as ever and she is now writing her own scripts, both literally and figuratively. She embarked on a master's degree in creative writing at Sussex University and, in March, her play, Be Mine, which deals with addiction and crime, goes into production for BBC Radio as a Play for Today.

She was inspired on her course by a fellow student who asked her if she had ever read any Raymond Carver because Malton's work had echoes of him. "So I devoured everything by and about Carver," she says. "He was also a recovering alcoholic and his inspiration was Chekhov so I studied him, too. I loved that attention to detail, everything pared down to the bone."

Helen Mirren as DCI Jane Tennison in Prime Suspect, 1991.

Her play is also much inspired by the work that she had now embarked on, as a trained addiction counsellor to the alcoholics and addicts who make up such a large proportion of our prison system. "I have used my addiction – which caused me huge shame – to liberate myself... I probably wouldn't have amounted to much if I hadn't been an alcoholic!" Now she is doing a second master's course, this time in addiction psychology, at South Bank University. And it is through this work that she came across one former robber…

Graham Godden's childhood was grim in comparison to Malton's. His father, a chronic alcoholic, disappeared six months after his son's birth and Godden was brought up in Folkestone by his mother and grandparents. He is now 47, and one of his earliest memories was the forbidding presence of Dover Borstal to which, as a treat, his grandfather would take him. "I would stand outside the gates just looking and thinking 'Wow, what goes on in there?' Now and then there'd be police and searchlights and I'd ask, 'what's going on?' and he would say, 'Someone's escaped.' Like Jackie, I was fascinated by the darkness – but from a different direction."

An angry and aggressive child, he was sent, aged 12, to a home for "maladjusted boys" for attacking a teacher: "We got into an argument and he was shouting at me and I was shouting at him and I punched him – just because there was an audience. If we had been in a room on our own, I probably wouldn't have."

The home was hellish. "I hated it. The older boys bullied the younger boys and the staff were bullies as well. Eight years ago, I was visited in prison by Kent Police because they were investigating what went on when I was there all those years ago." He ran away frequently, jumping on trains, staying with older "associates", but was always caught by the police. "I always resented the fact that, when I told them about the beatings-up I would get when they took me back, they weren't interested. So I hated the police with a vengeance."

When he emerged, at 16, already enjoying the illicit taste of cannabis and amphetamines, there was only one way to go. Brief periods of work in a soup factory and a supermarket were merely an overture to a career as a criminal. A father at 18 – he now has three grown-up children – he embarked on a series of solo robberies.

"My mum used to work in a building society and she once said, quite innocently, that, if people come in and demand money, they were told just to give it to them. That stuck in my head. She would have been horrified to know that that was why I chose building societies to rob." He was featured on Police Five, the television programme that asked the public to help in solving crimes, was caught and jailed for seven and a half years.

"When I was on trial for one robbery, I was confronted in court with a cashier in the witness box unable to say her name because she was so frightened and upset. I was still wrapped up in myself and trying to get a 'not guilty' but I remember thinking: 'I've done that.'"

On release, he moved on to heroin and went on a robbery spree that lasted 18 months. His modus operandi was simple: carry a weapon, go to a random provincial town, see somewhere with cash, rob it. In the summer of 1993, Crimewatch, a more sophisticated successor to Police Five, featured him as "the M25 Bandit" because so many of the robberies were, quite coincidentally, near the motorway. "I went on the run but, by the next month, Crimewatch had had 55 calls and could identify me. They said: 'We know who he is, now we need to know where he is.' Then the Sunday Mirror had a two-page article that the Flying Squad were looking for 'Britain's most wanted robber'. So Jackie and I both have the Flying Squad on our CV."

The next morning, Godden looked out of the window of his hide-out in Harlesden, west London, and saw two men with baseball caps and guns, members of SO19, the Met Police's firearms squad. He ran upstairs to hide his drugs. "Bang! The door went in and that was that." Within two years of his release in 1999 and after robbing a post office, he was back inside with a life sentence.

"I hated prison and I woke one morning and thought, 'Just what are you doing with your life?' My brother, an alcoholic and drug user, had died three weeks after I was arrested. I was 39 and had reached the end." A sympathetic prison officer pointed him towards a drug-treatment programme in Swaleside Prison and a long, slow process began. Godden realised that he needed to educate himself, which meant returning to the level of a 12-year-old's lessons; he is now on an Open University degree course in criminology and social sciences. He relapsed, after three years off drugs, while in Coldingley Prison and was making a slow recovery when, in 2007, a charismatic volunteer, herself a former alcoholic, came to talk to inmates who were trying to kick drugs and alcohol.

"The first time I heard Jackie, I didn't see a police officer, I saw someone talking about things I wanted to know about. I realised that I was still just skimming the surface. I asked her if she would be my sponsor [the person who acts as a mentor for recovering alcoholics and addicts in AA]. I was a thorn in the side of the police for a long time and I bought into the prison culture of 'we hate the police,' so it was quite cathartic to be working with an ex-officer. She became someone I respected and admired. It grew into a real friendship, a real love for another human being."

Graham Godden with Jackie Malton: 'Jackie and I both have the Flying Squad on our CV” Photograph: Suki Dhanda for the Observer

The feeling was mutual. "There was something that struck me about him," says Malton. "He was very focussed and honest about his past. I'd had my own demons so we could identify with each other." Godden was already involved, at the jail, in a crime diversion scheme in which young people at risk are shown the depressing reality of prison life and when he was finally released on licence in 2009, he wanted to do something similar. Unimpressed by many of the existing schemes, he came up with a programme called Youth Empowerment Crime Diversion Scheme. "Yes, we all agree it's a very clunky name," says Malton, "but it says what it does."

He and a team of ex-offenders work in schools with young people of 15 or 16, who have been in trouble or are at risk, on 12-week group programmes or in individual "interventions". Naturally, Malton became the chair of the trustees. Now, more than 3,000 young people have been through the courses, which have the backing of Kent and Sussex Police and are funded by charitable trusts and the National Lottery. But would something like that have had any effect on a teenage Godden?

"I wish I had a tenner for every time I was asked that," he says. "But everyone who tried to correct my behaviour was always someone in authority, which I reacted really badly to." Malton says she is "in awe" of how he goes about the work. "He can capture the children's attention in five minutes," she says. "He's gentle with them, but also firm in talking about life in prison. They're not going to listen to someone they can't identify with."

The Wimbledon hotel we're in is one where Malton once came for script meetings for The Bill, on which she was a consultant. The fictional Jane Tennison is part of the television crime canon so how do they both view the ways their very different careers are portrayed on screen? "Trainspotting was absolutely spot on about addiction," says Godden. "And I used to look at the film McVicar [about the robber John McVicar] and think: 'My God, I wish I was like him.' Now it doesn't interest me at all and I would have to say that my hero is Jeremy Paxman!" Malton loved The Wire, because it explored the complexities of crime, admired The Jury and Criminal Justice and is just about to settle down to the second series of the The Killing.

But it is a different kind of programme that interests them now. Does it actually work? Godden talks about a young girl who had been arrested 15 times in three months for setting fires and causing chaos. "We saw her. She engaged. She loved it. Three months later, she's joining the army. She said it was the best thing that ever happened to her. That's enough for me to keep going."

"And," says Malton, smiling over the teacups at the man whose collar she might once have felt, "you're enough for me to keep going."

youthempowermentcds.org.uk