Ali, 28, and his friend Ryan Hale, 27, are also standing trial accused of affray during the incident.
Off-duty police community support officer Mark Spure told Bristol Crown Court that Stokes had been the "main aggressor" in the group. He said "matters had become too serious to ignore and that I had to intervene".
Ben Stokes mocking gay clubbers.
The jurors were shown security camera footage of Ali and Hale holding beer bottles along with Kai Barry and William O'Connor, who the prosecution described as "flamboyant, extrovert and openly gay" regulars at the nightclub.
Police constable Stacey Alway, who arrested Stokes at the scene, said he was calm and compliant when she dealt with him. Stokes, of Stockton Road, Castle Eden, Durham; Ali, of Forest Road, Bristol; and Hale, of Burghill Road, Westbury-on-Trym, Bristol, each deny a joint charge of affray.
He added: "It was homophobic in nature". They had shown a willingness to use weapons in attacking people and were willing to gang up such that at points, the pair of them were attacking me on my own.More news: Google Pixel 3 XL smiles for the camera
More news: Deaths reported as massive quake hits Lombok
More news: ‘Secret life’: Rick Gates forced to reveal affair at Manafort trial
"These men were speaking to the gay guys in what I would call a harsh and abusive way", the statement said. Hales said: "I feel bad".
Stokes' police interview at the time lasted 21 minutes, and involved two handwritten statements.
"I made a decision to intervene and asked Ryan Ali and Ryan Hale to stop abusing Kai and William".
"I grappled with the second guy, in the course of that I can recall hitting him a couple of times".
"I didn't feel I had an option. Obviously it all happened very quickly but I am clear that I felt under threat of immediate attack from both these men and I did what I did only in order to defend myself".
Hale, who it is alleged was punched by Stokes in footage captured on a mobile phone and played to the jury on Tuesday, cycled to hospital later on Monday and was found to have sustained a 1.5 inch superficial laceration to his forehead.
She told the court the cricketer had been "squaring up" to a group of men at the side of the road as she approached them.