Members of the Bonnano crime family hired a Long Island detective to stage a fake police raid at an illegal gambling parlor run by their rivals, federal prosecutors said.

Prosecutors said the raid happened about a decade ago at a gambling parlor run by the Genovese crime family in the back of a Merrick shop called Sal’s Shoe Repair.

On Tuesday the former detective, Hector Rosario, 51, of Mineola, went on trial on charges of lying to the FBI and obstructing justice in the case. Prosecutors and his defense attorney said the trial in Brooklyn federal court will last about two weeks and feature testimony from a number of mafia members turned federal witnesses. If convicted, Rosario faces a maximum of 20 years in prison on the obstruction of justice charge and a maximum of five years on charges of lying to the FBI.

Rosario was fired from the Nassau County Police Department in 2022, a department spokesperson said.

“He chose the crime family over the public he swore to protect,” Assistant U.S. Attorney Anna Karamigios told jurors in her opening statement.

Rosario’s defense attorney, Lou Freeman, said there is more to the case than what prosecutors presented. He also told jurors to mistrust the testimony of witnesses who committed crimes themselves, and are cooperating with prosecutors in exchange for their own lighter punishments.

In her remarks to jurors, Karamigios said members of the Bonnano crime family looked to Rosario because they knew he would be willing to trade on his badge.

“They called in the defendant, a police officer they knew was for sale,” Karamigios said.

During the fake raid, Karamigios said, Rosario and other men dressed as police officers barged into the back area of the shop and broke a gambling machine.

The illegal parlors featured video gambling machines and raked in as much as $10,000 a month, prosecutors said. The Bonnano family ordered the raid to disrupt its competitors, prosecutors said.

Prosecutors said that in 2020, Rosario learned federal authorities were investigating his Bonanno family contact. He then tried to tip him off, passing him the name and address of a cooperating witness, prosecutors charged.

When the FBI questioned him, Rosario lied, denying he knew a mafia associate, and said he was not familiar with Sal’s Shoe Repair, according to prosecutors.

Freeman, Rosario’s defense attorney, tried to undercut the prosecution’s theory of the case on a number of fronts.

Freeman pointed to elements of the charges that he said don’t add up, including questioning whether the lie Rosario allegedly told the FBI was “material” to the investigation.

He added that one cooperating witness set to testify “made up information about Hector Rosario to get one more notch on his belt.”

Correction: Due to incorrect information provided to Gothamist, an earlier version of this story misstated how much prison time Rosario faces if convicted. He faces a maximum of 20 years in prison on the obstruction of justice charge and a maximum of five years on charges of lying to the FBI.