An NYPD detective who admitted to being a serial pervert — masturbating in front of girls outside their windows — got off with a measly desk-appearance ticket, authorities said Monday.

Detective Robert Francis, 46, of Queens was busted over the weekend for fondling himself in front of four female victims, including three girls under age 16, since Feb. 5, officials said.

The veteran cop, who at one point worked in the NYPD’s Internal Affairs Bureau, was caught with a flashlight in the driveway of a Rockville Centre, LI, home at around 2:30 a.m. Sunday, police said.

He would shine the light at victims’ homes to catch their attention and begin masturbating when they looked outside, police said.

He was charged with four counts of public lewdness, three counts of endangering the welfare of a child and four counts of trespassing.

Speaking to reporters Monday, Rockville Centre Police Commissioner Charles Gennario explained why the cop was just given a ticket.

“We do not perceive him a real danger to the community,” he said.

“We only charged him with misdemeanors. That’s all we could charge him with. He was not a danger in that sense that he was now known to us.”

But a high-ranking NYPD source called the move unusual, especially since Francis copped to being a repeat offender.

“That’s bulls- -t,” the source said. “We would never give somebody charged with those particular charges a [desk-appearance ticket]. People with less charges have been put through the system.”

Francis, a licensed helicopter pilot who works in the 71st Precinct in Flatbush, Brooklyn, told cops that he had the flashlight because he uses it to look into choppers, law-enforcement sources said.

He was suspended without pay from the NYPD after his arrest.

Gennario said all of Francis’ victims were local high-schoolers and that all were chosen randomly.

“He would drive into town,” the commissioner said. “He would leave his vehicle blocks from where he was going to victimize people. When [a victim] would go to get help, he would run away.”

Francis admitted to cops that he had committed the sick act in other jurisdictions, police said.

“He kept telling the investigating detective that he was going through tough times,” Gennario said. “I spoke to my detective just before we came in here, and he was concerned that he might harm himself.”

Francis has been in trouble administratively with the NYPD, losing up to 100 vacation days, police sources said. He was kicked out of the IAB after being accused of fudging his time sheets, sources said. He had been reduced to writing summonses, sources said.

Court documents show Francis filed for bankruptcy in September, listing $727,000 in liabilities.

A neighbor in Springfield Gardens was upset to learn of the bust.

“Just knowing that you have your young child walking there and he’s doing stuff like that — it’s very troubling,” said Troy Brewster, 51, who has a 16-year-old daughter.

A woman who answered the phone at Francis’ home hung up on a reporter.