efe-epaWashington DC

A gunman who injured six police officers in Philadelphia, Pennsylvania, on Wednesday evening and who had holed up in a house to avoid arrest, surrendered to authorities after midnight following an eight-hour-long standoff.

The incident began at 4.30 pm on Wednesday when police tried to serve a narcotics warrant.

"That went awry almost immediately," Police Commissioner Richard Ross told reporters, adding that a man inside the house opened fire and that some officers jumped out of windows and doors to escape the barrage of bullets.

Six police officers were injured and taken to hospitals but have since been discharged. Another was admitted for injuries sustained in a vehicle crash related to the incident, Philadelphia Police Sergeant Eric Gripp said on Twitter.

“It's nothing short of a miracle that we don't have multiple officers killed today,” Ross said.

Two other police officers had been trapped in the building along with three people they had arrested when the hours-long incident began.

A SWAT team later managed to evacuate the officers and those detained.

The authorities then urged the gunman to surrender and spoke with his lawyer to assure him that he would not be harmed.

It was not until past midnight that the shooter finally handed himself in.

Local newspaper The Philadelphia Inquirer said police sources had identified the suspect as local resident Maurice Hill, 36, who had a long history of gun convictions and resisting attempts to bring him to justice.

Following the incident, Philadelphia's mayor Democrat Jim Kenney on Twitter called for greater arms control.

"Our officers need help. They need help. They need help with gun control. They need help with keeping these weapons out of these people's hands," he said.

The White House said that President Donald Trump was briefed on the shooting.

The incident comes at a particularly sensitive time in the country following the recent mass shootings in El Paso, Texas, and Dayton, Ohio, in which a total of 31 people were killed. EFE