Andrew Fisher inflicted 32 wounds to the head, neck and torso of Craig MacKenzie, 40, before abandoning the victim in his flat.
Fisher, 48, later made a 999 call, confessed to the killing and told police where to find him, adding that his life was not worth living but "he didn't have the balls to do anything about it".
Defence counsel Robert Anthony QC told the High Court in Edinburgh: "I don't think I have come across a case with so many admissions to the offence."
Schizophrenic Fisher, who was jailed for life in 1990 after murdering his wife, was released from prison in 2001 and spent 12 years in the community with one driving conviction before killing Mackenzie at his home in Milton Street, in Edinburgh, on July 5 this year.
He was assessed as fit to plead and admitted killing MacKenzie by striking him on the head and body with a knife. The Crown accepted his plea to the lesser charge of culpable homicide on the basis of diminished responsibility.
Advocate depute Stephen McCloy said: "The deceased also had a previous conviction for murder and met the accused while they were both in prison and whist they were carrying out voluntary work with the same charity."
MacKenzie was jailed after he was convicted of the murder of 25-year-old David Edwards who was found to have suffered a catalogue of injuries after he was dug up from a shallow grave in Edinburgh's Seafield Crematorium.
Mr McCloy said on the day of the attack MacKenzie had attended a meeting of a homeless charity where he was involved in a project for offenders. He then went home.
Part-time shop assistant Fisher had travelled into the city from his home in Musselburgh, East Lothian, with his partner Sandra Whyte and went to help at a charity. He later returned home. The next day he called her on the phone and said he had "done something bad". Minutes later he made the call to emergency services and when police arrived at Musselburgh promenade he waved to officers and told them: "I've killed a guy called Craig, I don't want to go on any longer."
He was taken in a police van to show then the location. Mr McCloy said: "The accused appeared relaxed and calm and freely said on more than one occasion 'I've killed him' and 'He is in a bath'."
Police forced entry to the house and found the victim's body slumped over a bath.
He suffered defensive injuries to his hands and knife blows to the neck which cut carotid arteries.
Fisher told police he heard voices before but not during the incident. He said he "planned to kill Craig" and another man but could not get him as he was in Perth.
A psychiatrist who saw Fisher said the offence would have been significantly influenced by his mental illness.
Mr Anthony said it would be of concern to the public a man who had a conviction for murder had been released and gone on to commit such an offence.
But he added: "The public will be protected for many, many years if he is ever even released by the Parole Board."
He said that if Fisher, whose life sentence licence was revoked within days of the killing, was deemed fit to leave a psychiatric hospital he would be returned to the mainstream prison system. Lord Stewart heard Fisher required to be detained in hospital in conditions of special security at the State Hospital at Carstairs.
The judge ordered he be held at the hospital under an interim compulsion order for 12 weeks before he is returned to court when psychiatrists are expected to give evidence.