Facebook’s much-ballyhooed claim that it is cleaning up its act by cracking down on explicit content didn’t prevent the posting of a sex video linked to the grisly slaying of 15-year-old Lesandro Guzman-Feliz.

Cops suspect that the 17-second clip — which shows a leering young man having sex with a woman lying on a table — may have led a group of gang members to mistake Guzman-Feliz for a second guy who stands next to the copulating couple and raps, leading the gang to target the wrong person.

The X-rated posting came as Facebook has been running a massive ad campaign to rehabilitate its image in the wake of Russian political meddling and the Cambridge Analytica data-mining scandal.

“From now on, Facebook will do more to keep you safe and protect your privacy,” a narrator says in the commercial that’s been appearing on TV for weeks.

In late April, Facebook also unveiled new “Community Standards” that “restrict the display of nudity or sexual activity because some people in our community may be sensitive to this type of content.”

A law enforcement source said the graphic clip is believed to have been posted originally on Snapchat, which automatically deletes all postings after no more than 24 hours, and was then spread via other social media.

​Meanwhile, legal experts said incriminating messages apparently posted by one of the gang members on Instagram could prove extremely damning in court.

“There is no question that these messages will be admissible in a conspiracy case and put to use by prosecutors to seek to indict and convict as many members of the gang as possible for this terrible crime,” veteran defense lawyer Mark Bederow said.

​N​one of the social media giants returned requests for comment.