NEWARK, N.J. (CBSNewYork) — An off-duty Jersey City police officer shot and killed two armed men attempting to rob him, authorities said.

It happened around 12:30 a.m. Monday on South Sixth Street near 13th Avenue in Newark.

A 21-year-old resident said she was in her car at the time when she heard five or six shots and then saw a man speed past her on a bike. She then realized a body was in the middle of the street, she told CBS2’s Meg Baker.

“There was definitely a lot of shots and you can clearly tell they were right there next to us,” she said. “We were nervous.”

Authorities said the police officer was dropping off an acquaintance and two children when they were confronted by the alleged armed robber. One suspect attempted to fire at the officer and the weapon jammed. That’s when the officer responded with gunfire.

“My friend said, is that a bumper in the street? No that’s a body in the street,” the woman said.

The 21-year-old woman and her friend froze in fear.

“Someone was riding away on a bike, didn’t see us, didn’t get visual of him either,” she said.

The men who were killed were Dante Holden, 19, and Tymyr Wilson, 21, both of East Orange.

The woman said a police officer lives across the street. He hosted a cook out this summer for people on the block but she did not know which department he worked for, Baker reported.

The Essex County Prosecutor’s Office said the officer involved in the shooting is also a member of the DEA Task Force.

The officer was taken to University Hospital to be treated for trauma.

“We are thankful that our detective, who was a victim of an attempted armed robbery, is OK and want to thank the Newark Police Department and Essex County Prosecutor for their assistance in this ongoing investigation,” a city spokeswoman said.

Authorities have not released the names of the officer or victims.

The Essex County Prosecutor’s Office is investigating.