A detective who worked monitoring sex offenders for the NYPD Special Victims Division was arrested Friday for allegedly groping and trying to kiss an 12-year-old girl in Brooklyn, The Post has learned.

Juan Jimenez, 37, attacked a girl he’d hired to work as a babysitter in their Crown Heights apartment building, sources alleged.

Jimenez was ordered released without bail after a hurried arraignment in Brooklyn Criminal Court late Friday. Prosecutors had asked that he be held on $50,000 bail.

Court-assigned law enforcement then ushered him away from a Post photographer and out a back door.

Ironically, Jimenez worked for the Sex Offender Monitoring Unit; he was assigned to the criminal court building at 100 Centre St. in Manhattan, sources said.

He has been charged with felony sex abuse and misdemeanor forcible touching and endangering the welfare of a child.

“Defendant grabbed [the girl] about the waist with defendant’s hands, attempted to kiss informant about the mouth and grabbed informant’s buttocks with informant’s hands,” a criminal complaint alleges.

Additional reporting by Laura Italiano