PHILADELPHIA (AP) — A gunman who opened fire on police Wednesday as they were serving a drug warrant in Philadelphia, wounding six officers and triggering a standoff that extended into the night, is in police custody, authorities said.

Philadelphia police Sgt. Eric Gripp said early Thursday morning that the man was taken into custody after an hour’s long standoff with police.

The shooting began around 4:30 p.m. as officers went to a home in a north Philadelphia neighborhood of brick and stone rowhomes to serve a narcotics warrant in an operation “that went awry almost immediately,” Philadelphia Police Commissioner Richard Ross said.

The six officers who were struck by gunfire have been released from hospitals, Gripp said.

Two other officers were trapped inside the house for about five hours after the shooting broke out but were freed by a SWAT team well after darkness fell on the residential neighborhood. Three people who officers had taken into custody in the house before the shooting started were also safely evacuated, police said.

Temple University locked down part of its campus, and several children and staff were trapped for some time in a nearby day care.

Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.