“Wednesday was a heart-wrenching day for the city of Philadelphia,” said Mr. Kenney, a Democrat. “Whether it is mass shootings like we saw last week in El Paso and Dayton, guns have flooded American cities, leading to senseless — and preventable — violence.”

The police said narcotics officers had arrived on Wednesday afternoon at the 3700 block of 15th Street to serve a warrant. Larry Krasner, Philadelphia’s district attorney, would not say Thursday whether the warrant identified Mr. Hill, or whether it was for the house where the shooting took place. The Philadelphia Inquirer quoted sources as saying the warrant had been for a nearby home.

The gunfire began moments after the officers entered the house where Mr. Hill and several other people were. Four shots. A few minutes later, two shots.

Anthony Edward Fields, who lives directly across the street, said he came downstairs at about 4:45 p.m. to see more than two dozen police officers kneeling in front of his door while one of their colleagues was lying wounded on the sidewalk.

About 15 minutes later, Mr. Fields said, he watched the standoff from behind his front window and saw the police exchange many rounds of gunfire with the gunman.

“You’d hear one shot from the gentleman inside the house, and you’d hear 15 or 20 shots from the cops,” he said. “Every 20 minutes or 30 minutes, he would shoot at them, and they would return fire with maybe 10 to 20 bullets.”