MARTINEZ — A man who trafficked cocaine with a Mexican drug cartel testified in a murder case Thursday about his relationship with an allegedly corrupt Richmond police officer.

Sergio Vega-Robles, a former associate of the Sinaloa drug cartel, is now a key witness in the trial of Coby Phillips, 42. Phillips, the founder of an Irish-American street gang in West Contra Costa County, has been charged with murdering a drug dealer in Crockett and with putting out a hit on the attorney who helped turn Vega-Robles into a witness.

Vega-Robles, along with his brother, Jose Vega-Robles, sold drugs in Contra Costa and Solano counties during the early 2000s. Sergio Vega-Robles testified Thursday that he sold cocaine and that his brother sold cocaine and methamphetamine.

He said under oath that his brother made drug deals with Phillips, a founder of the Family Affiliated Irish Mafia, or FAIM. Sometimes, his brother would accept guns in exchange for drugs delivered to Phillips, and the guns would then be sent to Mexico, he said.

Sergio Vega-Robles testified that, unbeknown to others in the drug ring, he began giving information to authorities about local drug dealers. From 2003 to 2005, he said he worked as a confidential source and helped set up drug deals for federal and state investigations.

It wasn’t long before Sergio Vega-Robles started playing both sides of the fence. He said he began meeting privately with Richmond police Sgt. Michael Wang, who would give him cash seized from drug dealers police arrested.

Sergio Vega-Robles testified as well that he gave Wang more than $100,000 in drug money. He said Wang once told him the name of someone who had reported Jose Vega-Robles to police. The man was later shot.

In 2005, Sergio Vega-Robles and Phillips became co-defendants in a drug trafficking case, leading Phillips to discover Sergio Vega-Robles had been talking to police. Sergio Vega-Robles said he was attacked in jail soon afterward, but under cross-examination, he said he told police he suspected Wang had him beaten.

Phillips’ attorney, Dan Horowitz, said Sergio Vega-Robles repeatedly asked officers what they wanted him to say during interviews. He has accused Vega-Robles of fabricating stories implicating Phillips to get favorable treatment in his criminal case.

Vega-Robles is an undocumented immigrant but has been permitted to stay in the United States in exchange for his testimony. He also admitted to owing the cartel several thousand dollars, which Horowitz has argued gives him an extra motive to lie under oath.

FAIM formed as a gang out of the Crockett/Rodeo area in the mid-1990s and is mainly composed of Irish-Americans. Phillips, one of four founders, gained a reputation as ruthless but intelligent. Prosecutors say Phillips and other FAIM members made hundreds of thousands of dollars during the 1990s, selling methamphetamine and buying houses and expensive sports cars, and investing in local businesses.

Wang, no longer a police officer, has not been charged with any crimes, according to Contra Costa senior deputy district attorney Barry Grove. Grove said there was a “long story” why Wang was never charged, but he deferred all questions to Tom Kensok, the prosecutor handling Phillips’ murder trial, who declined to comment.

Sergio-Vega Robles also testified that after he got back from a trip to Mexico, his car was missing. He said his brother later told him that he, Phillips and a third man — Josue “Primo” Lomelli — had used it to meet with an Aryan Brotherhood-affiliated drug dealer named Darryl Grockett, and that Grockett had been shot and killed.

Horowitz pointed to earlier statements where Vega-Robles told police Phillips “wasn’t stupid” enough to confess to him and that Phillips didn’t trust him.

Lomelli’s whereabouts are unknown. Jose Vega-Robles was convicted in Grockett’s killing. In 2013, a jury deadlocked on murder charges against Phillips, resulting in a mistrial.

Since Grockett’s killing, Phillips has been accused of soliciting Jason Soletti, a fellow inmate at Contra Costa County Jail in Martinez, to kill Sergio Vega-Robles’ attorney.