Police used controversial facial-recognition technology to track down an accused rapist fewer than 24 hours after he tried to force a woman into sex at knife-point on Friday, cops said.

Civil liberties advocates have cautioned the tech could lead to false arrests, but law enforcement experts say the tech is a “boon” for Big Apple cops hunting down alleged creeps like 27-year-old Maximiliano Mejia before they strike again.

Mejia is accused of stalking a 29-year-old woman for 45 minutes on Friday before trying to kidnap and rape her at knife-point in near Southern Boulevard and Bedford Park in The Bronx.

Cops said Mejia had followed the woman from her work — nearly two miles away near Walton Avenue and Fordham Road — and grabbed her at about 10:15 p.m.

He allegedly dragged her about 60 feet into a grassy area and started unbuttoning his pants, authorities said.

The woman pleaded with him and crossed herself — and eventually, he relented, according to cops.

“Don’t tell anyone,” Mejia allegedly said to the woman before pushing her to the ground and running off, according to police.

But he was in cuffs by 4:30 p.m on Saturday — before he could strike again — thanks to the Facial Identification Section, which to compared HD video from a nearby food store to mug shots, the NYPD said

Mejia was arrested in June 2018 for allegedly raping a 73-year-old woman, but he’s been out on $10,000 bail.

Eugene O’Donnell, a professor at John Jay College and former NYPD officer, said this case highlights the benefits of the technology for police.

“Chances are this wouldn’t have been solved,” O’Donnell said. “It’s not when it’s solved — it’s if.”

The former cops effect arrests in rape cases at a notoriously low rate because of the resources and manpower it takes to identify a suspect, and the crime is historically repeated — and often escalated.

“A rape on Tuesday can be a rape and a murder on the following Tuesday,” he said. “Relying on humans instead of machines has been a boon for criminals and terrorists for that matter.”

Critics, though, are wary of the technology in law enforcement’s hands.

Noah McClain, a professor who’s studied New York City subway-security, said he’s concerned about the tool’s accuracy.

“What if you look like one of these sex criminals? You’ll have a problem day in and day out,” said McClain, an assistant professor at Illinois Institute of Technology.

“There’s an incredible danger as being identified as someone suspicious because it could lead to an encounter with police and go down a path it wasn’t meant to go down,” he said. “Some people may have few rights because of how this works.”

In a recent report by Georgetown professor Clare Garvie — titled “Garbage In, Garbage Out: Face Recognition on Flawed Data” — slams the NYPD’s use of facial recognition.

The paper revealed cops had used a photo of Woody Harrelson to hunt down a look-alike beer thief using thousands of cameras around the city.

“The stakes are too high in criminal investigations to rely on unreliable — or wrong — inputs,” Garvie wrote in the scathing report.

The New York Civil Liberties Union has also questioned the NYPD’s use of the technology.

The NYPD, however, says the tech simply complements other law enforcement practices.

“No one has ever been arrested based solely on a positive facial recognition — it is a lead, not probable cause,” an NYPD spokeswoman told The Post.

“Stopping perpetrators of horrific violence and bringing justice for survivors is our mission and this technology — as used responsibly — has proven to be valuable in combating crime.”

Mejia faces multiple charges, including attempted rape, and was jailed on $150,000 bond, according to the NYPD.