An Atlantic City police officer has been cleared in the fatal shooting of a man who stabbed the officer last June during an encounter captured on police body cameras, prosecutors said Monday.

The officer, who was not identified, shot Timothy Deal, 32, of Atlantic City, on the evening of June 22 in the 600 block of North Kentucky Avenue.

“It has been concluded this use of deadly force was legally justified,” the Atlantic County Prosecutor’s Office said in a statement. The New Jersey Attorney General’s Office concurred.

Police and fire personnel had responded to a hit-and-run traffic accident with injuries when Deal, carrying a pointed object in his right hand, suddenly approached one of the officers. Video from the two police body cams shows the officer drawing his gun and yelling, “Put it down! Put it down!”

Deal can be seen lunging toward the officer who then fires several shots while stepping backward. Deal collapses and was later pronounced dead at AtlantiCare Medical Center City Campus. The Prosecutor’s Office said the officer also was taken to AtlantiCare and was treated for a stab wound to his torso and released.

The Prosecutor’s Office said the video recording was consistent with accounts from witnesses at the scene, including members of the Fire Department who responded to the traffic accident.

On the video, the officers are seen speaking with a man standing next to a child when Deal appears. “The police officer involved in this matter acted in self-defense to protect him and the public from the imminent danger posed by Mr. Deal,” the Prosecutor’s Office said.