The decision by appeal judges now opens the way for Alexander Reid, 62, to ask the parole board to free him – something he could not do while still a patient in the State Hospital, Carstairs.
Reid's victim, Angela McCabe, 26, was stabbed to death as her four-week-old baby daughter lay upstairs in her crib in her home in Bishopbriggs, East Dunbartonshire.
Reid was accused of murder. But in court his guilty plea to a reduced charge of culpable homicide was accepted.
Judge Lord Walker heard evidence from doctors and sent teenage Reid to the State Hospital "without limit of time".
But during his time in Carstairs, where he is thought to be the longest serving patient, doctors came to believe there had been a mistake.
Back in 1967 tests appeared to show Reid was suffering from a mental disorder which would today be classed as learning disability. The Court of Criminal Appeal in Edinburgh heard psychiatrists now label Reid's problem as an untreatable dissocial personality disorder.
His legal team successfully argued the change in diagnosis amounted to new evidence allowing Reid to appeal.
Five appeal judges, instead of the usual three, yesterday quashed the 1967 decision to send Reid to Carstairs and substituted a life sentence.
Reid has completed the 10 year minimum the judges attached to the life sentence, opening the way for him to seek parole.
Lady Paton, giving the judges' ruling, said Reid's crime was "horrific and appalling".
She added: "Reid, then aged 17, brutally attacked and killed a young woman, then aged 26, who had earlier given him a cup of tea after he had sharpened gardening tools for her.
"The attack happened in her own home while her husband was at work and she had the care of their young child.
"It was a terrible and senseless crime, resulting in the loss of a young wife and mother and inflicting lasting grief and suffering on her bereaved family."
In 2007, Reid's legal team came to the Court of Criminal Appeal in Edinburgh to challenge Lord Walker's ruling of 40 years earlier – but lost. Backed by the Scottish Criminal Cases Review Commission, which investigates possible miscarriages of justice, Reid was given another chance.
Dr Natasha Billcliff, responsible for Reid's care in the State Hospital, told the appeal judges he was "disruptive", needed more time and attention than any other patient and spurned attempts at therapies. Nothing the hospital could do was likely to improve his condition. Other medics said if Reid was sentenced now he would probably not end up in hospital.
The appeal judges were told that while prisoners can be transferred to the State Hospital "administratively" there was no such mechanism for sending Carstairs patients to prison.
In 1985, Reid was sent, for a time, to a hospital in Montrose on the basis his problem was a personality disorder rather than illness. While on a day out he was arrested for attempting to abduct an eight-year-old child.
Reid, judged sane and fit to plead, served a three month prison sentence before being sent back to Carstairs.
Lord Johnston, one of the judges involved at an earlier stage, said it was a "supreme irony" that, for the first time in his career as a judge, a man was actually asking to go to prison.
Reid's long-running campaign has involved four applications to Lanark Sheriff Court and a challenge in the Court of Session to one sheriff's decision.
When that was rejected he went to appeal judges at the Court of Session. They ruled in his favour but the then Secretary of State successfully appealed to the House of Lords. Reid had also taken his case to the European Court of Human Rights.