Updated

The NYPD is searching for a third suspect following a shooting that left a New York City police officer wounded by friendly fire during a drug arrest.

The plainclothes detective and his partner, both veterans of the narcotics unit, had stopped a car in Brooklyn on Tuesday around 6:15 p.m. while investigating a suspected heroin deal.

“Tonight’s shooting is an important reminder of the critical and dangerous work our police department does each day,” New York City Mayor Bill de Blasio said in a statement. “Today, a detective put his life on the line as he bravely performed his duty to protect our city and its residents from harm.”

The injured officer, 36, was listed in stable condition Wednesday with two gunshot wounds to the shoulder. He was alert and talking, police told Newsday.

"He is in good spirits," First Deputy Commissioner Ben Tucker said.

Police said the officer was reaching into the vehicle when the driver took off in reverse, striking a police car and dragging the officer.

Both officers used their weapons, firing a total of four shots, officials said.

The 45-year-old driver was shot in the leg and wrist. A second person in the car also was taken into custody. Charges against them were pending. Police said both men had multiple previous arrests. The driver had 58 prior arrests and the other man had 17, officials told Newsday.

A third man in the car fled.

The shooting marked the sixth time since January a New York City police officer has been shot in the line of duty.

Last month, Officers Andrew Yurkiw and William Reddin were shot during a confrontation with a gunman in Brooklyn. Yurkiw was shot in his bullet-resistant vest and Reddin was struck in the hip.

A little more than two weeks before those two officers were shot, Officers Diara Cruz and Patrick Espeut were shot and wounded while on patrol in a public housing stairwell in the Bronx. The gunman later killed himself, police said. In January, Officer Sherrod Stuart was wounded in the ankle by a police bullet as another officer exchanged gunfire with a suspect in a Bronx street brawl.

The Associated Press contributed to this report.