A New Jersey man who was attempting to break into cars in a residential neighborhood in Montgomery County tried to kill a police officer who confronted him, prosecutors said Thursday.

Reynaldo Figueroa-Ardon, 20, of Vineland, was arrested late Wednesday and charged with attempted murder of a law enforcement officer, assault of a law enforcement officer, receiving stolen property, and related offenses. He remained in custody Thursday, in lieu of $3.5 million bail. It was not immediately clear whether he had hired an attorney.

Prosecutors say Whitemarsh Township Police Officer Matthew Stadulis encountered Figueroa-Ardon while responding to reports of someone pulling on door handles of parked vehicles, seeing if they were unlocked, according to the affidavit of probable cause for his arrest.

Figueroa-Ardon refused to stop and talk with Stadulis, the affidavit said, and the officer chased him a short distance. Figueroa-Ardon then pulled out a 9mm handgun, aimed it at the officer’s head and pulled the trigger several times, the affidavit said.

The gun did not go off, and Stadulis wrestled Figueroa-Ardon to the ground and disarmed him, according to the affidavit. During the fight, Figueroa-Ardon tried unsuccessfully to grab the officer’s handgun, the document said.

The gun Figueroa-Ardon was carrying was loaded but had no bullets in its chamber, according to the affidavit. Authorities said Figueroa-Ardon admitted to detectives that he tried to shoot the officer.

The gun had been reported stolen to Pennsylvania State Police in Skippack, the affidavit said. Its owner said it had been taken out of the center console of his vehicle.

Figueroa-Ardon is not permitted to possess a weapon because he came to America illegally from El Salvador, according to court records. He possesses a certificate of residency under the Deferred Action for Childhood Arrivals policy, and therefore cannot be removed from the country.