A former New York City vice squad detective ran a multi-million dollar brothel empire beginning in 2008 when he was still a member of the police force, and he got away with operating the prostitution ring with help from his buddies inside the department, in what The New York Times called “the worst NYPD scandal in years.”

But on Tuesday, 51-year-old Ludwig Paz, who stepped down from the New York City police department in 2010, entered guilty pleas to three counts of corruption and promoting prostitution. On June 27, Paz will find out how long he will spend behind bars as a result, with a maximum sentence of 12 years for his crimes, according to the Times report.

Paz’s 43-year-old wife, Arelis Peralta, also pleaded guilty to two corruption charges for helping her husband operate the brothel enterprise in the New York City boroughs of Brooklyn and Queens, as well as in Long Island’s Nassau County, according to The New York Post.

Peralta was sentenced to 364 days—one day short of a year—in jail. Why her sentence was significantly lighter than what her husband is now facing remains unclear, according to The New York Daily News.

Paz and Peralta stayed ahead of police investigators both by receiving inside tip-offs of upcoming raids or arrests, as well as by using Paz’s own knowledge of vice enforcement rules and procedures. For example, knowing that undercover cops were not permitted to reveal their genitalia to prostitutes in the course of an investigation, Paz required all prospective customers to disrobe upon entering one of his brothels, according to a Times summary of the case.

Seven active police officers were arrested and accused of helping Paz run the brothel ring by providing him tips about when officers planned to raid or investigate one of the brothels. As a result, when cops showed up, often responding to neighbor complaints about the brothel activity, they inevitably found nothing that seemed criminal and left empty-handed.

One of the cops who tipped off Paz about pending raids and investigations was his former partner on the vice squad, Rene Samaniego, who entered a guilty plea on May 8. Paz reportedly paid his former partner $500 per week for information, such as physical descriptions of undercover officers sent to investigate the brothels.

The crooked cops busted in the investigation were sometimes paid in cash—and sometimes in sexual favors, according to a Postmedia News report.

But Paz was finally caught when one cop tipped off the NYPD Internal Affairs division about the crooked cops involved in the operation.

Photo By Gcin1987 / Wikimedia Commons