Alan Finnie, then a taxi driver, said he slowed down after seeing what he thought was an accident as he headed back to the centre of Edinburgh after dropping off a fare. He told the High Court in Glasgow he then heard "an almighty bang".
Mr Finnie was giving evidence at the trial of Mohamud Mohamud, 30, Ahmed Ahmed, 28, Cadil Huseen, 23, Hussein Ali, 26, Liban Ahmed - also known as Jama - 30, Said Fadal, 32, and Said Tarabi, 27. They all deny murdering Mohammed Abdi, 25, in Duddingston, Edinburgh, on May 26 last year.
Mr Finnie told prosecutor Iain McSporran that he initially slowed down as a small dark car was heading towards him at speed on the wrong side of the road.
He said: "When I got to the junction of Abercorn Crescent there was a car sitting in the middle of the road. I thought there had been an accident. When I slowed down I saw another car - a people carrier - lying in a hedge. I was going to phone the emergency services, but things changed somewhat when I heard a loud crack - a gunshot - it came from Abercorn Avenue."
The jury was played the tape of Mr Finnie's 999 call in which he said: "I heard a f***ing almighty bang. There's a car in a fence and black guys running around. I'm positive I've just heard a shot or something being fired."
Mr Finnie, from Edinburgh, said that by the time he finished his call a police car had arrived and he went over to assist them.
He said one officer appeared to have detained a man and the other was helping an injured man.
The trial has heard that Mr Abdi was taken to Edinburgh Royal Infirmary by ambulance and pronounced dead at 1.56am.
Earlier yesterday, a crime scene examiner told the murder trial he found an automatic machine gun hidden in undergrowth.
Mark Heron, 49, was called out at 5am, He told advocate depute Iain McSporran, prosecuting: "An automatic machine gun could be seen. It was partially obscured by branches and undergrowth."
Earlier the court heard that Mr Abdi was shot three times and pathologists said that the fatal wound was to his chest.
Mr Abdi's father Oman Abdi, 59, who is a lecturer in Arabic and Somalian, described his son as a "kind and helpful person to me".
He revealed that on May 3, 2013 he had been shocked when the home he shared with his son at Buchanan Street, Edinburgh, was raided by police who found illicit drugs.
It is alleged that the seven accused repeatedly fired a sub-machine pistol and a revolver after a car chase along Dudding-ston Road West, Willowbrae Road and Abercorn Avenue.
The seven are accused of forcing the car occupied by Mr Abdi, Mohamed Farah and Abdulrakim Abdulrahman to stop by colliding with it and repeatedly shooting at the occupants, murdering Mr Adbi and attempting to murder the other men.
All seven deny all the charges against them.
The trial, before judge Lord Turnbull, continues.