A New Jersey police officer was busted by FBI agents Friday for allegedly dealing crack and heroin — sometimes right out of his cop car, according to federal authorities.

Ruben McAusland, 26, who worked for the Paterson PD, was caught selling roughly $12,000 in drugs to an undercover buyer who was working with the feds, US Attorney Craig Carpenito said in a statement Friday.

The crooked cop is accused of selling at least 35 grams of marijuana, 48 grams of heroin, 31 grams of cocaine and 31 grams of crack between October 2017 and April 2018, according to Carpenito.

“It’s a surprising case — that an officer, who is supposed to be preventing the sale of drugs, did just the opposite,” said Will Skaggs, a spokesman for Carpenito.

On Feb. 11, 2018, McAusland allegedly met the undercover buyer in his police cruiser at a supermarket parking lot, near police headquarters, and sold him four sample heroin pills, authorities said.

He then sold the buyer larger hauls of the pills on several other occasions, including 1,010 pills for $7,000 on April 1, the federal authorities said.

He also sold the buyer marijuana, heroin and cocaine in October 2017, according to authorities.

McAusland, who had worked for the police department for four years, faces a maximum of 40 years in prison for narcotics distribution.

He posted a $100,000 bail bond and was released Friday.