Sentence was deferred on Allister Gibb, 32, following the attack on Robert Chalmers in May, only hours after Chalmers had been convicted of murder.
Gibb’s solicitor said he had been extremely upset after the case, which heard how Chalmers had dumped the body of 24-year-old Samantha Wright in a wheelie bin in Duddingston.
He told police he intended to hurt only Chalmers, and even apologised to the Reliance security guards who were escorting Chalmers from the High Court in Edinburgh.
The incident stunned onlookers following the conviction of 59-year-old Chalmers – nicknamed Papa Smurf.
As the killer was being led away to face his life sentence, Gibb, of Calder Crescent, Sighthill, pushed passed security, doused him in petrol and attempted to ignite the fuel with a lighter.
When that failed because security guards managed to get the situation under control, he made his way down the Royal Mile before police caught up with him outside Deacon Brodies bar, at which point he was entirely co-operative.
The NHS worker has pleaded guilty to endangering the life of Chalmers and two security guards who were with him.
His solicitor, David Storey, told the court yesterday that he had made his apologies, and that no-one sustained injuries.
He added: “It was a sensitive issue. He was very upset at losing his girlfriend.”
A tearful Gibb was comforted by his lawyer as he was led away.
He will be sentenced next month at which point, Mr Storey said, he will give a full explanation of his act.
The court also heard yesterday how Chalmers – who was also convicted of murder in Renfrewshire in 1973 – watched television in his home as Samantha lay dead in his bin.
He kept her body there for months before police discovered her hand protruding through leaves outside his home.
The discovery ended a search which began when her family reported her missing nine months earlier.
Her parents, from Hertfordshire, sat through his May 2011 trial and expressed relief when he was found guilty.
Depute fiscal Ian Wallace said: “Chalmers was handcuffed to the Reliance officers and was on his way to the van when Mr Gibb appeared standing beside the Reliance van.
“Mr Gibb was carrying a 500 millilitre bottle which he had filled with petrol.
“As Mr Chalmers was being led away Mr Gibb threw the petrol over him from the bottle.
“The liquid landed on his clothes and it also struck the security guards.”
Mr Wallace said that in the chaos that followed, guards managed to get Chalmers into the van but Gibb was so filled with rage that he managed to squeeze past and get himself into the vehicle.