A man allegedly attempting to impersonate a police officer tried to take the law into his hands by pulling over a van full of real detectives, police said Saturday.

Valiery Portlock, 25, drove his black Nissan Sentra on northbound on Hicksville Road in Hicksville, Long Island, around 11 a.m. Friday when he activated his air horn and flashing lights and drove behind the van.

In this Aug. 16, 2019 photo provided by the Nassau County Police Department in Hicksville, N.Y., 25-year-old Valiery Portlock is shown.

The detectives, while stopped in traffic, exited the van and identified themselves as members of the Nassau Police Department’s Electronics Squad.

Once they tried to approach Portlock’s car, Portlock allegedly fled the scene, swerving into oncoming traffic and speeding away from the officers on the Long Island Expressway, police said.

The chase then continued.

Nassau County Highway Patrol eventually spotted Portlock and initiated a traffic stop before taking him into custody.

Portlock was arrested and charged with first-degree criminal impersonation, reckless endangerment, and unlawfully fleeing from a police officer.

Other criminals have tried to play fake cop only to see themselves on the other side of the law.

In July, a Florida man impersonating a police officer got himself into hot water when he pulled over an off-duty cop, and in January 2018, a California man got himself into trouble when he pulled over an off-duty sergeant.