An hours-long standoff ended with the surrender of a man who shot several Philadelphia police officers.

Maurice Hill, 36, was taken into custody around midnight on Thursday morning, according to NBC Philadelphia. He was taken to Temple University Hospital for evaluation before he was returned to police custody.

The standoff occurred on Wednesday around 4:30 p.m. after officers traveled to the Nicetown-Tioga neighborhood in suburban Philadelphia to act on a narcotics warrant. Hill barricaded himself in a building with several hostages and exchanged gunfire with the police. Six officers were shot, including one whose head was grazed by a bullet. All the officers were taken to local hospitals, treated and released. None of the injuries were life-threatening.

The hail of gunfire sent officers retreating. Some escaped by jumping out of windows, and two officers were trapped with Hill’s other hostages. Hill was reportedly armed with an AK-47. The gunfight lasted for about an hour, according to ABC News. The standoff lasted about seven hours before officers gave Shaka Johnson, Hill’s lawyer, an 11:45 p.m. deadline for negotiations.

"We are trying to talk to this male, trying to let him know that he can end this peacefully now," Philadelphia Police Commissioner Richard Ross said during the standoff. "We have called him multiple times. He's picked up the phone a couple times, but he has not answered.”

CNN reports Hill eventually walked out of the building with his hands up around midnight after a SWAT team deployed tear gas. The hostages were recovered safely.

Johnson, who has represented Hill for years, said he doesn’t believe his client intended to engage in a shootout with the police. He also revealed his client is the father of a newborn baby.

Philadelphia Mayor Jim Kenney spoke in favor of gun control during a late-night press conference.

"It's aggravating. It's saddening," he said. "It's just something we need to do something about. And if the state and federal government doesn't want to stand up to the NRA and some other folks, then let us police ourselves. But they preempt us on all kinds of gun control legislation."

Kenney believes gun control could have protected the injured officers.

"They don't deserve to be shot at by a guy for four hours with an unlimited supply of weapons and an unlimited supply of bullets," he added. "It's disgusting and we've got to do something about it. And we need to do something about it quickly."

Hill has a long criminal history including theft, narcotics and gun charges, according to CBS Philly.

Hill will likely be charged with six counts of attempted murder and aggravated assault.