A Harlem restaurateur linked to the NYPD corruption probe was detained Tuesday in his first appearance in Manhattan federal court on charges of running a $12 million Ponzi scheme after prosecutors revealed that senior police officials referred investors to his scam and traveled with him to the Dominican Republic.

During the bail hearing, prosecutor Russell Capone also said that Hamlet Peralta, 36, one-time owner of the Hudson River Cafe, attracted one member of the NYPD as an investor in his phony wholesale liquor business as well as a member of organized crime.

Peralta is charged with luring investors with forged documents and false promises, and spending the money on his own lifestyle or to pay back others. He was first arrested in Georgia 2 1⁄2 weeks ago. On Tuesday, Magistrate Frank Maas set his bail at $5 million with $1 million security, and Peralta was unable to post it.

His victims allegedly included Jona Rechnitz, one of two Brooklyn businessmen under scrutiny in the NYPD corruption probe, accused of giving gifts to police brass. He faces up to 20 years in prison.

Capone said Peralta’s “confidence was bolstered by his close relationship with the NYPD.” He “cultivated” ties with senior officers in his precinct, the prosecutor said, and one of the officers who traveled with him to the Dominican Republic was “very, very high ranking.”

The prosecutor also argued that Peralta fled to Georgia immediately after he was approached on the case by an FBI agent, and an NYPD connection immediately ran a check for warrants after Peralta was stopped for a traffic violation in Georgia.

He said the federal case was bolstered by wiretaps, and his “close connections in law enforcement, including people who can fix things for him,” made him a flight risk.

Peralta’s lawyer, Cesar de Castro, said Peralta went to Georgia for a job, not to flee, and that he hadn’t used any of his connections to get away in the past; He asked for $300,000 bail.

The NYPD corruption probe has already triggered disciplinary action against several senior police officials and charges against a Rockland County man accused of paying bribes for gun licenses. It is linked to federal and state investigations of Mayor Bill de Blasio’s campaign fundraising.