A New Jersey cop lost his job after pleading guilty to doing heroin in his patrol car, officials said.

Franklin Township police officer Matthew D. Ellery, 29, admitted to possession of heroin and driving while intoxicated after being found slumped over in his squad car while on drugs, according to the Somerset County Prosecutor’s Office.

The incident took place on April 7, when cops attempted to reach Ellery by radio but he failed to respond.

Another officer was dispatched to the location and discovered Ellery unresponsive in the driver’s seat.

The unresponsive officer was revived after receiving two doses of the opioid overdose reversal drug Naloxone.

As part of his plea agreement, Ellory will apply for admission into the five year drug program and must forfeit his job as a police officer.