"Suspect is in custody. SWAT is still clearing the house," Philadelphia Police Sgt. Eric Gripp tweeted early Thursday.
The shooting started at 4:30 p.m. Wednesday and was followed by a standoff that lasted nearly eight hours.
Two officers and three others who had been trapped inside the row house were evacuated by a SWAT team a few hours before the standoff ended, Philadelphia Police Commissioner Richard Ross Jr. told reporters.
"They were able to use stealth to do it," he said, adding he didn't think the shooter was aware of the rescue mission.
Before the standoff ended, negotiators had been trying to communicate with the shooter, but the gunman was only picking up the phone without answering, Ross said at one news conference.
Authorities trying to convince him to surrender were making a little bit of progress. The man's attorney joined a phone call and tried to assure the suspect that police were not going to harm him.