NYPD officers were executing a search warrant when they spotted the suspect, 33-year-old Kelvin Stichel, on Decatur Street around 6:40 a.m. in the Bedford-Stuyvesant section.
Stichel was wanted for charges connected to a domestic armed robbery, according to the NYPD.
The officers followed Stichel in an unmarked police car, but eventually confronted Stichel on foot. Officers said they identified themselves and ordered him to display his hands, and that's when Stichel opened fire.
Police said Stichel fired approximately six rounds at officers, who returned fire.
32-year-old Detective Miguel Soto, who's assigned to the Brooklyn North Warrants Squad, was struck by one of the bullets in the leg and rushed to Kings County Hospital by fellow officers.
The seven-year NYPD veteran was released from the hospital Friday afternoon.
Officials call Soto a "highly decorated tough street cop" who has chased down many armed suspects during his career and had been awarded a Medal of Valor. In 2013, Soto narrowly avoided being shot by a suspect who pointed a gun at him near a Brooklyn playground. Soto fired first, striking the man twice.
The suspect ran from the scene, but police followed a trail of blood and found Stichel nearby at 39 Kingston Avenue.
Stichel was also wounded during the initial shootout in the upper right thigh and taken to a hospital for treatment. Investigators recovered a weapon from the scene.
He was charged with attempted aggravated murder among other charges.
Police Commissioner James O'Neill said the suspect has numerous previous arrests, including one for assaulting a police officer.
"This morning's incident highlights the extremely difficult work the men and women of the NYPD perform on a daily basis on behalf of all eight and half million New Yorkers in all five boroughs," O'Neill said.
The shooting comes a year and a day after the deadly shooting of NYPD Detective Miosotis Familia, who was ambushed and killed in a parked police vehicle.
City officials renamed part of Ryer Avenue by the Bronx stationhouse where Familia worked in her honor on Thursday.
* More Brooklyn news
* Send us a news tip
* Download the abc7NY app for breaking news alerts