Six police officers were shot during a wild gun battle in Philadelphia on Wednesday afternoon — sparking a massive, hours-long standoff that was still going on as of 8:30 p.m., according to officials.

The cops were conducting a drug raid on a house in Philly’s Nicetown-Tioga neighborhood when a male suspect began blasting at them with some sort of rifle, police said.

Additional forces, including SWAT teams, descended upon the home around 4:30 p.m. and could be seen returning gunfire.

Officials told reporters that the male suspect had barricaded himself inside, and was shooting at responding officers from within the residence.

“Even when I was on scene, he fired multiple rounds — many of which struck the SWAT truck,” said PPD commissioner Richard Ross at an evening press conference.

Sources told CBS3 that the suspect was live-streaming some of the mayhem — and that cops were trying to take the footage down.

Officials said the man was “holed up” inside a multi-family residence, along with two officers and several others. They would not say whether the other individuals were being held hostage, only that they were inside the house with the suspect.

At least six officers got hit by bullets and were rushed to Temple University Hospital. Their injuries are not life-threatening, according to police.

“They’re all in good spirits,” said Mayor Jim Kenney.

FOX 29 tweeted that witnesses reported hearing more than 100 rounds fired before police arrived — and said at least one of the cops got shot in the head. Officials later clarified that he had been grazed.

Authorities swarmed the residential neighborhood and closed off surrounding streets, with video from news choppers showing officers crouching behind cars. Sources told CNN that SWAT was drawing up plans for a possible forced entry into the suspect’s home.

Cops were still exchanging fire with the man and trying to get him to surrender as of 8:30 p.m., according to officials.

“Officers are attempting to communicate with the shooter; imploring him to surrender and avoid further injuries,” tweeted Philadelphia Police Department Sgt. Eric Gripp.

Commissioner Ross later added, “We are trying to get him to come out peacefully, but right now he refuses to do so.”

Shortly before 5 p.m., Philadelphia Police Sgt. Eric Gripp wrote on Twitter that the news choppers were “hindering operations” and should pull back. He said the shooting was in the 3700 block of North 15th Street and urged residents to avoid the area.

A seventh police officer was also said to have been injured in a car crash, officials said, though it’s unclear how the incident was related to the drug raid and ensuing shooting.

The cops who got shot were described as members of the Philadelphia Police Department’s Narcotics Strike Force.

“Our concern right now is for them and for their families, and we’ll sort out all of the other stuff when the scene has been resolved over where the shooting has took place,” said Mayor Kenney. “We’re thankful, a little angry about someone having all that weaponry and all that firepower, but we’ll get to that another day.”