He said that no matter what the history, “nothing justified the frenzied attack” on William Meek in June 2008 which led to his death in “horrible circumstances”.

“This was an appalling case perpetrated by an individual who lost control of himself, very probably because of self-induced intoxication and drug taking,” the judge told Antrim Crown Court, sitting in Belfast.

The judge added that by setting fire to Mr Meek's Causeway Street flat in Portrush, Allen had “seriously endangered the lives of others”.

Earlier this year Allen, from Glenarm Avenue in Portrush, pleaded guilty to murdering 35-year-old Mr Meek on a date unknown between June 23 and June 26, 2008 and to wounding him with intent on February 13, 2008.

Prosecuting QC Richard Weir told the court that in February Allen and Mr Meek met “by chance” and drank together in a disabled toilet on Portrush's East Strand.

According to Mr Meek, he was attacked “for no reason” as he walked away in the early hours of the morning, sustaining 14 stab wounds to his head and neck. However, defence SC Philip Magee told the court that Allen claimed he had awoken to find Mr Meek sexually interfering with him.

Mr Weir said Allen was released on bail over that attack but that four months later on June 25, the pair again met “entirely by accident” on Causeway Street and Allen began “remonstrating” with Mr Meek over the alleged attack, and the pair ended up drinking together in Mr Meek's flat.

The Fire Service were called to the flat at around 6.15am and Mr Meek was dragged from it with his head and face covered in blood, said the lawyer, and he was pronounced dead at the scene an hour later.

He told the court the investigation revealed Mr Meek had suffered 51 stab wounds to his head, face and neck but that a pathologist had stated the most likely fatal wound had penetrated “almost the entire breadth” of his skull and brain.

The Fire Service found two seats of fire, one downstairs and one on the mattress upon which Mr Meeks was lying. The lawyer added that the pathologist found soot in Mr Meek's lungs, indicating that he was probably still alive when Allen set fire to his flat.

Allen was found about an hour later, lying “comatose” under a hedge in a garden in Dhu Varren Park South and was arrested for the murder, which he denied during police interviews.

Mr Weir told the court that in the Crown view the murder was aggravated because of the extensive and multiple injuries inflicted, the fact that Allen tried to destroy the crime scene, and because of the previous assault and criminal convictions for assault, robbery and burglary.

Mr Magee said it was clear that Allen “deeply resented” the previous sexual assault and that when he went into Mr Meek's flat in June after meeting him by “pure and horrible mischance” he “just flipped and saw red” after Mr Meek invited him into his bed.