LONG BRANCH — A homicide investigation turned deadly this weekend when police went to an apartment with a warrant and encountered a man who began shooting at them, striking an officer, prosecutors said.

The gunman was eventually killed by police after an hours-long standoff.

Officials said that while the officers were in Apartment 1 of 274 Chelsea Ave. on Friday evening, a man entered the room and opened fire, hitting an officer in the leg.

Officers retreated and the man barricaded himself until officers said gunfire erupted inside the apartment about 2 a.m.

The man came out as he fired his weapon and officers shot back, prosecutors said.

274 Chelsea Ave, Long Branch. (Google Maps)

One of the officers' shots struck the man, who was eventually pronounced dead at the scene, according to the state Attorney General's Office, which routinely investigates police-involved shootings.

The officer who was shot was released from the hospital Friday evening.

State officials said the initial warrant involved a homicide investigation but they did not publicly release other details, including the name of the man who was killed.

First Responders Appreciation