(Updates throughout with comments from police commissioner, mayor, condition of officers, identity of suspected gunman)
By Andrew Hay
Aug 14 (Reuters) - A SWAT team rescued two police officers and three civilians trapped inside a Philadelphia house with an active gunman after a shootout in which six officers were wounded, police said on Wednesday.
The gunman remained barricaded inside the home, with police urging him to surrender and media reporting he was armed with a semi-automatic rifle similar to the popular AK-47 style and several handguns.
Police moved in about five hours into the standoff that began after the gunman opened fire on officers as they served a drugs warrant inside the north Philadelphia home.
SWAT officers used stealth to rescue the officers and three suspects inside the house without the gunman knowing they had entered the home, said Philadelphia Police Department Commissioner Richard Ross.
"We've gone from a hostage situation to a barricade because all the hostages were taken out safely," Ross told reporters.
He said it was "astounding" there had not been a greater tragedy.
All six wounded officers were released from hospital on Wednesday night, one officer surviving after a bullet grazed his head and another after a bullet hit body armor on his back.
"Many of them had to escape through windows and doors to escape from a barrage of bullets," Ross told a news conference.
The gunman fired on a SWAT truck parked outside the residence in the Nicetown-Tioga neighborhood, with rounds peppering buildings across the street as residents cowered inside homes.
The Philadelphia Inquirer, citing police sources, identified the suspected gunman as Maurice Hill, 36, a Philadelphia man with a history of gun, drugs and assault convictions.
Attorney Shaka Mzee Johnson, who court documents show recently represented Hill, did not respond immediately to a request for comment.
Ross said the gunman stopped firing as night set in.
"We're optimistic that means that he's starting to understand that there's some benefit of him coming out," Ross said.
The incident followed a string of mass shootings in California, Texas and Ohio in which gunmen used semi-automatic rifles.
Philadelphia Mayor Jim Kenney said he was angry the gunman was able to amass such firepower.
"We've got to get these weapons out of people's hands," Kenney said after visiting wounded officers in hospital. "This government, both on a federal and states level, don't want to do anything about getting these guns off the streets and out of the hands of criminals."
President Donald Trump was monitoring the situation in Philadelphia, according to the White House. (Reporting by Andrew Hay, additional reporting by Alex Dobuzinskis; Editing by Cynthia Osterman, Sandra Maler and Lisa Shumaker)