The teenager accused of murdering schoolboy Bailey Gwynne was seen with a knife "maybe 25 times" before the fatal stabbing, a witness has told a court.

The 16-year-old witness also said he had seen the teenager with knuckledusters “40, maybe 50 times” before the attack on October 28.

On Wednesday, he told the murder trial: "He thought [the knife] was cool. I said not to bring it to school."

The witness, who described himself as a “close friend” of the accused, said he had purchased knuckledusters "off eBay or somewhere online".

Bailey, 16, died of his injuries at Aberdeen Royal infirmary following the incident at Cults Academy last year.

He suffered a stab wound to the heart during a fight with a 16-year-old boy, who cannot be named for legal reasons, according to a joint minute read out to the High Court in Aberdeen on Tuesday.

The witness said the fight which ended in Bailey’s death began after the 16-year-old exchanged heated words with the accused following a row over a packet of biscuits.

On Wednesday the 16-year-old witness said: "Bailey had biscuits. The rest of them just had sweets. I didn't have any lunch that day so I asked Bailey for a biscuit and he gave me one.

"I asked him for a second one and he said no as I think he had only one left."

The jury heard evidence that there was then an exchange of insults between the accused and Bailey, during which Bailey's mum was called "fat".

The witness said: "Bailey turned round and said 'what did you say?'

"I was really shocked. Bailey was known for not fighting back. People would say stuff to him and he would just not say anything back."

The court heard the pair then started pushing and grappling with each other.

The boy said Bailey was hitting the accused against the wall with his head in a headlock when he reached into a pocket and "thrust" an object into Bailey's chest.

A teacher then broke up the fight and began walking them to see the school's senior management seen.

But around 165ft up the corridor, Bailey collapsed beneath a TV screen used for school announcements.

The witness said: "I don't even think Bailey realised [he had been stabbed] at that point. They made him walk all the way across school to the other side. I don't know how they didn't notice he was bleeding all the way."

Later on Wednesday the paramedic who treated Bailey gave evidence.

Gary Gillespie, 46, who has been a paramedic for 16 years, told the court: "He was probably the palest person I've ever seen. He was gasping for breath.

"His paleness indicated catastrophic blood loss and it was clear early on that it was a huge internal blood loss.

"I asked a member of staff to raise his feet to get more blood to his organs. I cut off his blazer and managed to get IV access to put a plastic tube into one of his veins.

"The ambulance crew arrived [and] it was about that point the patient's heart stopped.

"I started chest compressions [but] there was no change in his condition. He was placed in an ambulance and we left the scene.

"On the way to the hospital I was trying to stop the bleeding. I saw a 2cm puncture would on his chest."

The advocate depute asked Mr Gillespie if there was anything else he could have done to save Bailey, to which the paramedic replied: "No".

Police officer Christopher Masson also gave evidence on Wednesday.

He said in the moments following the fight the accused asked him, "Is he dead?”, before adding, "It was a moment of anger".

Officer Masson told the court he had recovered an empty knife sheath from the inside pocket of the accused’s blazer and that a teacher handed his colleague a knuckleduster.

The accused began sobbing in the dock as Mr Masson gave his evidence to the court.

The trial is expected to last a further three days.