Charles Murray,45, said he saw the males attack Mark Squires outside a Hearts FC supporters club in Longstone Road, Edinburgh on October 22 2017.
The High Court in Edinburgh heard how the two men had been at a charity night to raise money for a friend who had suddenly died.
Mr Murray said that after the night out ended, the two men stood in a street to hail a taxi to take them home.
But Mr Murray told a jury on Monday that he saw three men assault his friend.
He said: “They were kicking him on the head and body. They swarmed on him.”
Mr Murray, of Edinburgh, was giving evidence during the second day of proceedings against Nico Allan, 24, Aiden Welsh, 25, and 20-year-old Liam Tierney.
The three men deny murdering Mr Squires at Burnside Lane near Longstone Road, Edinburgh and other charges.
The court heard Mr Murray say he had known Mr Squires since he was a wee boy at school and that they had remained best friends.
They had shared an interest in football. Mr Murray was a Manchester United fan but Mr Squires supported Hearts and Liverpool.
He told the court they had been in the Longstone Hearts supporters club a few times.
He added: “This time we were doing a charity night for a friend.
“We had a friend who had suddenly passed away at the age of 48. We decided to try and raise some money for his family.
“We just tried to raise enough money to help his family a little bit.”
Mr Murray, an engineer, told prosecution lawyer David Taylor that football memorabilia had been collected and a race night organised at the Hearts club.
Mr Murray said: “Mark was selling a lot of football tickets. The other guys that organised it were doing lots of stuff as well.”
He said they got a taxi to the club from Mr Squires’s home after having a couple of cans of beer and remained at the venue until shutting time.
He said that during the evening Mr Squires won a prize of cosmetics and added: “I think he was going to take it home to his mum.”
Mr Murray said that he and Mr Squires were drinking pints of lager during the evening. He said he was tipsy and added: “But I was aware.”
He said of Mr Squires: “I think he was the same as me. He would have been merry.”
The court heard that at the end of the evening, the two men realised there no taxis were available. They took the decision to head to a takeaway in Longstone Road to get some food and order transport from the shop.
However, the shop was closed and the two men waited to see if they could hail any taxis.
Mr Murray said that the two men became involved in an altercation with three men.
The court heard that Mr Murray was allegedly assaulted as well.
Mr Murray said that he became involved in a confrontation with a man who was wearing a top with “stripey sleeves”.
He added: “I thought i was grappling with him at some point.”
Mr Murray said that after the confrontation, he saw Mr Squires lying on the ground.
He said: “I gave him a tug. I said ‘come on Mark let’s go. Let’s get a car.’
“But he didn’t open his eyes. I panicked a wee bit. I phoned an ambulance and I gave him CPR.”
The court heard that Mr Squires looked “pretty bad and battered.”
Prosecutors claim that on October 22 2017, at Burnside Lane near Longstone Road, Mr Allan, Mr Welsh and Mr Tierney repeatedly punched, kicked and stamped on Mr Squires head and body.
The trio are also alleged to have “caused” Mr Squires head to “strike off a wall” and that they then struck him over the head with a glass bottle.
The crown claim that the three men severely injured Mr Squires and that they murdered him.
Prosecutors also claim that on the same date and that location, the three men repeatedly punched and kicked Mr Murray on the head and body.
It’s also claimed that on the same date, at a nearby location, the three men behaved in a “threatening and abusive manner” by shouting, swearing, and fighting with people “unknown” to the prosecutor.
Mr Welsh is also accused of taking the clothes he was wearing at the time he allegedly attacked Mr Squires and spraying them with breach at a house in Edinburgh’s Balgreen Gardens.
Prosecutors say he did this weigh the intention of attempting to “defeat the ends of justice.”
The Crown also claims that between October 22 2017 and October 24 2017, at an address in Edinburgh, Mr Allan attempted to defeat the ends of justice.
He is said to have tried to get a woman called Chloe Adams and his co accused Mr Welsh to tell police officers that they didn’t see him strike Mr Squires with a bottle.
The Crown allege that he did this with the intention of avoiding “detection, arrest and prosecution.”
The three men, who all come from the Edinburgh area, have pleaded not guilty to all charges.
In relation to the murder charge, the trio have lodged special defences of self defence.
The trial, before judge Lord Tyre, continues.