Police shot and killed a man in Woodbridge Township, New Jersey who was suspected in an attempted homicide earlier this month, law enforcement officials in New York and New Jersey said. An NYPD detective and a Woodbridge Township police officer were also shot and injured, officials said.

The shooting happened after New Jersey law enforcement officials used license plate readers to track the suspect’s car to the Royal Albert’s Palace hotel and banquet hall in Fords, a part of Woodbridge Township, New Jersey Attorney General Matthew Platkin said in a news conference on Thursday afternoon.

New Jersey officials called in the NYPD because the police department was investigating the initial attempted homicide that took place in Manhattan earlier this month.

The NYPD detective and Woodbridge Township police officer waited at the hotel on Wednesday evening for the suspect to arrive, according to NYPD Assistant Deputy Commissioner of Public Information Carlos Nieves.

In the exchange of gunfire, the NYPD detective was shot in the foot and the Woodbridge Township police officer was also shot and injured, Nieves said. Both law enforcement officials were in the hospital recovering from their injuries as of Thursday afternoon, Platkin said.

At least one top NYPD official, NYPD Deputy Commissioner of Operations Kaz Daughtry, responded to the scene on Thursday morning after news broke of the detective being shot, Nieves said.

The incident that prompted officials to track the man to New Jersey took place on June 7 on East 105th Street in Manhattan, according to Nieves. The NYPD received a 911 call about shots fired at around 8:30 p.m., and arrived to find a 29-year-old man who had been shot in the head, Nieves said. Witnesses told police they heard four shots fired, according to Nieves. The victim, who was walking home with his brother that night and whose name has not been released by police, was not the shooting's intended target, Nieves said.

Platkin had originally described the man as a "homicide suspect" but the NYPD later clarified that the shooting victim is technically still alive but brain-dead at Cornell Hospital, according to Nieves. The man's family is waiting for his mother to arrive from Venezuela before removing him from life support, Nieves said.

The intended target of the Manhattan shooting got away, Nieves said.

Platkin said officials were not yet releasing the name of the suspect, pending family notification about his death.

“This incident is another reminder that our law enforcement officers risk their lives daily to keep our communities safe,” he said in an earlier statement, adding that his office was working with New York City and Woodbridge police to investigate what happened.

The New Jersey Attorney General’s Office of Public Integrity and Accountability is legally required to review all shootings and deaths involving police officers. Under state law, the investigation will be presented to a grand jury. Video footage of the shooting will be released “at the earliest possible time” once the investigation is underway, Platkin said.

Correction: A previous version of this story misstated the New Jersey attorney general's first name.