The alleged suspect who shot at police is wheeled to a nearby ambulance.

A wanted gun-wielding parolee in a mask was killed early Monday in a fierce firefight involving seven police officers after he shot at a patrol car in Brooklyn, cops said.

None of the officers were hurt in the gun battle, police said.

Uniformed officers were on patrol near Howard and Dumont avenues in Brownsville about 2:30 a.m. when they saw a suspicious person wearing a mask, NYPD Chief of Department Terence Monahan said.

“When the officers who were inside their patrol car attempted to speak to the man, he immediately fled toward 788 Howard Ave.,” Monahan said at an early morning press conference.

“One officer exited the vehicle and the other two drove onto Howard Avenue,” he said. “The perpetrator fired numerous rounds at their vehicle, striking it. The officer who exited the car then exchanged gunfire with the male. However, the perpetrator fled from the officers.”

About 30 minutes later, a local resident alerted other officers that a man was trying to break into a backyard on Howard Avenue, the chief said.

As responding officers entered the backyard, they came under a hail of gunfire and “became pinned down at the location” as a result of the gunman firing, he said.

Additional officers, including those from the Emergency Service Unit, also made entry into the backyard area, where the man continued shooting.

“Our officers returned fire and the man was then taken into custody,” Monahan said.

The gunman, who was later identified by sources as 29-year-old Bloods Gang member Brandon Clayton, was taken to Brookdale Hospital, where he was declared dead.

A semiautomatic handgun was recovered at the scene.

According to a high-ranking police source, Clayton was on parole for weapons possession and had been wanted for absconding from parole.

Audio of police radio transmission obtained by The Post captured the moment the suspect was nabbed.

“We have one in custody at this time,” an officer can be heard saying.

Earlier in the audio a cop states: “Be advised that the perp may be white with some sort of body armor.”

A total of seven cops fired their guns – one on Howard Avenue and six others in the backyard, the chief said.

“There were a lot of rounds fired. Approximately nine rounds were fired by our officers on Howard Avenue. It’s still an approximation, but in the backyard it looks like we fired 55 rounds,” Monahan said.

“We’re still counting his shell casings to see how many he fired but he fired both on Howard Avenue and in the backyard,” he added about Clayton.

“The great work by our cops today demonstrates, once again, how they never hesitate to go into harm’s way to keep our city safe,” the chief added.

One local woman who heard the commotion said “it was like a war zone out here” when the bullets were flying.

“They were shooting out here for half an hour. It was hard to keep track of how many shots were fired because it went on for so long,” said the woman who lives on Grafton Street. “At one point we had to all go stand in the living room because we didn’t want to be near the window.”

Another neighbor, a retired city probation officer, called it a “chaotic scene.”

“So many police officers and police cars descended on the block. Way over a dozen,” he said. “I could hear a lot of gunfire. They came up to our homes and told us to stay away from the windows.”

Video posted to the Citizen app shows the moment a hail of bullets flew as a horde of officers zoned in on the location.

“Oh, they shooting,” the woman filming the video is hear saying. “Close the window, close the window.”

Additional reporting by Natalie Musumeci