BALTIMORE (WJZ) — Former Baltimore and Philadelphia police officer Eric Snell pleaded guilty to charges he sold drugs supplied by a corrupt BPD gun unit.

His surprise plea happened on the third day of his trial.

His lawyer David Solomon said it was his client’s own text messages shown to jurors the day before that lead to Snell’s change of heart.

“He saw the light. The text messages were devastating, and I think he had to see it for himself. It was probably useless to proceed,” Solomon said. “You can’t cross-examine text messages.”

“At least he has closure and the opportunity at sentencing to make a compelling argument for some kind of a break,“ Solomon added.

Snell became ensnared in the scandal through his ties to disgraced ex-detective Jemell Rayam. The two met at the BPD academy 13 years ago. Rayam was the best man at Snell’s wedding.

Former BPD Officers Testify In Latest Corruption Trial For Stealing Drugs, Cash

Rayam had already entered his own guilty plea and testified against Snell for the government. He told jurors was it was “difficult,”

Rayam testified that when he was desperate to get rid of cocaine he stole while on the Gun Trace Task Force, he turned to Snell.

He needed to pay back his sergeant, Wayne Jenkins, as well as cover gambling debts.

Body-worn camera video played in court showed the GTTF taking cocaine from a suspect during a traffic stop near Mondawmin Mall in 2016. Most of that cocaine eventually made its way to Snell, who used his connections to sell it on the streets of Philadelphia.

United States Attorney Robert Hur said Snell “disgraced his badge” but Hur would not say whether his office plans to charge any more officers in the scandal.

“To the extent that there’s facts and there’s evidence that suggests other misconduct…and folks who have not been brought to justice…we will not rest, and we’ll follow the facts wherever they might lead,” Hur said.

Snell faces 20 years in federal prison. He will be sentenced in January. “At least he has closure and the opportunity at sentencing to make a compelling argument for some kind of a break,“ said his attorney.

Acting Baltimore City Police Commissioner Gary Tuggle said officers involved in specialized gun and gang units now must undergo random polygraph tests. “We’re going to be aggressive about doing that. It’s really, really important that not only the public be assured of the level of integrity of our specialized units but also our federal counterparts,” Tuggle said.

“Any behavior of this type is just simply not acceptable, and I’m here to represent the good men and women of the police department,”

Follow @WJZ on Twitter and like WJZ-TV | CBS Baltimore on Facebook