“There is also a suggestion from the accused in interview that he was looking for monies to be refunded from a previous purchase as the tablets he received were in the accused’s words ‘dud’.”

Ms Edwards told the court the content of the texts sent between the two.

She said: “The exchange of text messages provide a flavour of the row between the accused and the deceased over drugs and money.

“In a text timed at 5.50pm, the deceased told the accused that ‘Ah don’t do tick as they are not mine, so if you want to be like that, bring it on, I don’t need your business once a fortnight.’

“In response in a message to the deceased at 5.54pm, the accused texted ‘meet me now ya p***k I’m puttin’ my coat on. I’ll get you at the circle Fanny.’”

Moments before the confrontation, the court heard that Mr Beveridge asked a man Gary Walkingshaw (38) to hand him a knuckle duster.

Ms Edwards added: “The deceased also took off his jacket and gave it to Walkingshaw to hold.

“A verbal confrontation followed, between the accused and the deceased, and in the course of this confrontation, the witness Walkingshaw stated that he noticed something glinting up the accused’s sleeve.

“The deceased repeatedly struck the accused on the head with the knuckle duster.

“The accused was in possession of a knife and struck the deceased around the head causing two superficial injuries and one penetrating wound to the left side of his neck.

“The witness Walkingshaw was ultimately able to disarm the accused and thereafter threw the knife onto the pavement out of harm’s way.”

The court heard that medical staff tried to save Mr Beveridge’s life. However, he died on October 16.

Police arrested Paterson. He told officers that the attack was “over a tenner”.

He was arrested and brought to court.

Lord Armstrong gave his condolences to members of Mr Beveridge’s family who were sitting in court.

He told Paterson: “You have pleaded guilty to a grave crime. There are no circumstances which can justify the taking of another person’s life.

“It is inevitable that a substantial custodial sentence will follow.”

Sentence was then deferred for the court to obtain reports about Paterson’s character.

He will be sentenced at the High Court in Glasgow on August 11 2017.

Commenting afterwards, Detective Chief Inspector Rory Hamilton, who led the investigation, said: “A man has lost his life and another now faces prison over a debt amounting to just a few pounds. This was a tragic incident and I wish to extend my sympathies to James’s family and friends.

“It was an isolated incident with both the deceased and the offender known to each other, but it still affected the community in Kirkcaldy and I’d like to thank them for their assistance and support during this investigation.”