Bail was denied for two men charged with a gang-related shooting Wednesday night that targeted a vigil for a rival gang member who was killed nearly a decade ago.

Prosecutors said the shooting was related to an ongoing conflict between gang factions that had resulted in a dozen shootings already this year.

Earnest James, 19, faces a felony count of aggravated discharge of a firearm, and Malicjawanza Smith, 21, was charged with felony counts of aggravated fleeing and unlawful use of a weapon by a felon, Cook County prosecutors said at their hearing Saturday at the Leighton Criminal Court Building.

About 8:45 p.m. Wednesday, 15 people were attending a vigil at Ridgeway Avenue and Ohio Street when Smith pulled up in a vehicle and James fired into the crowd from the passenger seat, prosecutors said.

A 25-year-old man was shot multiple times and rushed to Stroger Hospital, where he was listed in critical condition, authorities said. The gunfire also struck a 27-year-old man who drove himself to Mount Sinai Hospital for treatment.

Prosecutors said officers saw Smith and James driving in the area after hearing the gunfire and that Smith sped away when the officers tried to pull their vehicle over, blowing a stop sign and a red light as he fled.

The pair eventually bailed from the vehicle and led the officers on a brief foot chase, prosecutors said. Smith was seen tossing a loaded handgun before being taken into custody. A second loaded handgun was found in the passenger side of the vehicle where James had been seated.

Prosecutors said Smith admitted to opening fire at the group, but said he claimed he was also being shot at.

Smith, an alleged member of the Chicago Avenue Traveling Vice Lords street gang, had targeted the group as they held a remembrance vigil for a member of the rival Conservative Vice Lords who was gunned down nine years earlier, prosecutors said.

The two gang sets are embroiled in a “violent conflict” that prosecutors said could be blamed for 12 shootings this year in the Harrison District on the West Side, including Wednesday’s attack.

Prosecutors said Smith is currently on parole for a 2016 burglary for which he was sentenced to three years in prison. James had no other criminal history, they said.

Prosecutors attempted to enter evidence at the hearing that included social media posts dating back to 2016 that allegedly showed James and others armed with guns. James’ defense attorney, Nathaniel Niesen, said there was no proof that the guns in the pictures were real and claimed it’s “highly questionable that those photos could be admissible” in court.

Judge David Navarro said he would not take the social media posts into account in his consideration for bail for the two men. Ultimately, both were denied bail.

Smith and James, who both live in East Garfield Park, are expected to appear in court again on Wednesday.