The suspected gunman who opened fire in Philadelphia and allegedly hit six police officers, “did not want the incident to end violently”, according to a lawyer who helped end the stand-off.

Maurice Hill was taken into custody in the early hours of Thursday, at the conclusion of a seven-hour drama that saw dozens of heavily armed Philadelphia police officers surround a property in the city’s Nicetown-Tioga neighborhood.

Police commissioner Richard Ross, who told reporters he was both shot at and involved as a negotiator during the stand-off, praised officers for bringing it to an end without anyone losing their life.

“[It] could have been far worse,” he said, speaking out the department’s headquarters. “This was a very dynamic situation, one that I hope we never see again.”

Mr Ross also gave credit to a lawyer who is understood to have spoken with Mr Hill, 36, during the seven hours he was surrounded by police, and urged him to surrender.

“I gave his attorney, Shaka Johnson, a lot of credit that he came, and he was able to certainly engage him in conversation much longer,” he said.

Mr Johnson told KYW-TV he was Mr Hill’s lawyer and that he received a call from him at around 8.30pm, some four hours into the stand-off. At the time, he was watching events on TV.

“I realised who it was. The game for me became getting him out of there safely,” said Mr Johnson. “He did not want this to end violently. I told him you got to surrender now.”

Suspect in Oslo mosque shooting appears in court

Police used tear gas to force the suspect from the property, where he had first been approached by drug squad officers.

At times, the situation grew chaotic and police used social media to ask the media not to give away tactical information that could be useful to the suspect.

They also urged a media helicopter to keep away from the scene.

Donald Trump weighed in on the incident on Thursday morning, saying on Twitter the gunman “should never have been allowed to be on the streets”.

Philadelphia district attorney Larry Krasner said Mr Hill had not yet been indicted, but was likely to be charged with attempted murder.