Allister Gibb,32, threw the potentially lethal liquid over Robert Chalmers,59, outside the High Court in Edinburgh in May 2011.
He then pushed aside shocked security guards and tried to set him on fire using a cigarette lighter.
But Edinburgh Sheriff Court heard on Tuesday how stunned security guards managed to regain control of the situation - and pushed him away before he could spark a fireball.
Horrified solicitors, advocates and members of the public, also witnessed the shocking incident which took place on the Royal Mile.
Chalmers had been convicted at the court a few hours earlier of killing Samantha Wright,24, before dumping her body in a wheelie bin in Duddingston, Edinburgh, in October 2009.
The court heard how distraught Gibb wanted to get on his back on Chalmers who kept Sam’s body in a wheelie bin for months.
The court had heard how Chalmers - who was nicknamed Papa Smurf - callously watched TV in his house whilst Samantha’s lifeless body lay just feet away.
Gibb, of Calder Crescent, Edinburgh, pleaded guilty to endangering the life of Chalmers and Reliance security guards Alan Simpson and Kevin McDonagh before Sheriff Stephen Arthurson QC.
Depute fiscal Ian Wallace told the court: “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. Petrol landed on the witness Simpson’s left shoulder and his neck and his leg.
“It also also landed on Mr McDonagh who was in the van.”
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.
He said: “Mr Gibb managed to squeeze past Mr Simpson and get into the van - by using a cigarette lighter he tried to set light to Mr Chalmers’ clothing. “He was unsuccessful. He was pushed out of the van and he made his way up Bank Street. Police later attended the scene and later managed to arrest Mr Gibb outside Deacon Brodie’s pub.”
Chalmers was jailed for life in June 2011 for killing Samantha at his home in Duddingston, Edinburgh in 2009.