Three former New York police officers and a former prosecutor were arrested and charged in Manhattan federal court Tuesday as part of an ongoing federal investigation into a years-long gun licensing bribery scandal.

The four men were charged with conspiracy to commit bribery and several other offenses related to the scheme, in which gun licenses were approved in exchange for cash, booze, free guns, and even “the services of prostitutes,” the Department of Justice said in a statement.

Acting Manhattan U.S. Attorney Joon H. Kim said the corruption “spawned a cottage industry of parasitic profiteers, alleged bribers masquerading as so-called expediters.”

“Corruption was allegedly pervasive at the NYPD’s License Division going up as high as Lt. Paul Dean, until recently the division’s second in command, and including three other officers, Sgt. David Villanueva, Officer Robert Espinel and Officer Richard Ochetal,” Kim said.

Among those charged Tuesday were Dean, who had the ultimate authority to approve and reject gun licenses, and Espinel, a former officer who worked under Dean. Villanueva and Ochetal also answered to Dean. They previously pleaded guilty and are cooperating with authorities.

According to a criminal complaint unsealed Tuesday, the four men accepted bribes from so-called gun license expediters beginning in 2013. One of those expediters was Gaetano “Guy” Valastro, a former NYPD detective who was also arrested and charged Tuesday.

In exchange for lavish bribes from Valastro and other expediters, the officers would process gun license applications far quicker than usual, sometimes processing them the same day. The NYPD receives about 5,000 gun license applications annually, and the process takes several months, sometimes even a year. More than 100 gun licenses were issued as part of the bribery scheme, and the officers involved often sidestepped the usual due diligence of the gun licensing process.

In the complaint, prosecutors explain that Villanueva and Ochetal approved applications submitted by individuals with significant arrest histories that include convictions like weapons-related misdemeanors, domestic violence, and, in at least one instance, a felony conviction.

Also charged Tuesday was lawyer John Chambers, who served as as an assistant district attorney in Brooklyn from 1983 to 1985. Prosecutors say Chambers bribed Villanueva from 2010 to 2015, giving him tickets to sporting events, sports memorabilia, free meals, and an $8,000 wristwatch.

“I am so happy,” Chambers wrote to Villanueva in a text message, according to charging documents. “There are plenty of cases out there…we can be picky and only take those willing to pay the fare……but it would be nice to be able to do a handful a year together.”

Last month, Alex “Shaya” Lichtenstein, a former neighborhood patrol leader in Brookyln, was sentenced to 32 months in prison for bribing Villanueva and Ochetal.

“In return for a fee ranging from $10,000 to $16,000 per application, Lichtenstein purportedly assisted his clients in navigating the gun licensing process within the NYPD,” reads a Justice Department news release. “However, rather than provide legitimate services for his exorbitant fees, Lichtenstein instead bribed two officers in the NYPD’s Licensing Division to ensure success for nearly all of his clients’ applications.”

At one point, in a meeting with Espinel and Villanueva, Dean told Lichtenstein he was planning to retire and start his own expediting outfit.

“I’m done watching people make money off of my back,” said Dean, according to a recorded conversation obtained by the FBI. “I’m the one whose signing off on everything, I’m the one who’s taking care of everything…you’re making money. You and dozens of other people.”

“The light clicked on about six months ago, when I’m sitting there and watching everybody get cash hand over first,” Dean said.

“Two thousand, five thousand, ten thousand,” Espinel added.

On its website, the NYPD acknowledges the existence of gun license expediters, and offers a warning to residents. “These firms cannot obtain a handgun license or rifle and shotgun permit for you if you do not qualify, nor can they expedite your application,” the warning reads.

Dean, 44, and Espinel, 47, were each charged Tuesday with two counts of conspiracy to commit bribery and one count of extortion. Valastro, 58, was charged with two counts of conspiracy to commit bribery and one count of making false statements. Chambers, 62, was charged with one count of bribery and one count of conspiracy to commit bribery.

All four men were released on bond.