PHILADELPHIA — A gunman who shot and wounded six Philadelphia police officers trying to serve a drug warrant surrendered early Thursday morning following a tense hourslong standoff, authorities said.

About 15 popping sounds and billows of smoke were seen shortly after midnight as police fired teargas into the home, followed by shouted commands.

“Police, put your hands on your head and come out front," police yelled repeatedly through a bullhorn.

“Keep your hands up, keep your hands up, keep your hands up.”

Soon after, the command was, "Go on the ground, go on the ground.”

All six officers who were shot were transported to local hospitals but later released, Philadelphia police Sgt. Eric Gripp tweeted. Another officer was admitted for injuries "sustained in a vehicle crash related to the incident," he said.

The gunman, whose name has not been released by law enforcement, was taken to Temple University Hospital for treatment related to the teargas, police said.

"We are very, very lucky with six police officers shot in one incident ... It is nothing short of astounding that ... we didn't have more of a tragedy," Philadelphia Police Commissioner Richard Ross Jr. told reporters, describing the situation as "volatile."

Residents were lingering in the early evening around the perimeter of the crime scene, an area that is typically busy with shoppers, diners and people returning home from work.

“It’s like a war zone,” Marica Bing said.

“It’s really scary that this is going on in a regular residential area,” Asya Richardson added.

On her way home from work, Kiersten Gray saw helicopters and police cars and decided to stop at the scene.

“This is absolutely insane,” she said.

For Rysheana Hightower, Wednesday's situation was a terrible reminder: Her brother, Rashid, was shot and killed in the area 14 years ago, she said.

“The sickness of some of the individuals in the world we live in,” she said. “The world is a sad place.”

Nearby Temple University tweeted updates on the situation, instructing students to seek shelter. Their Health Sciences Center campus was briefly on lockdown.

Sophie Nicholas, a Temple student who lives near the scene, said she was visiting Aurora, Colorado, on the same day in 2012 that a gunman opened fire in a movie theater, killing 12 people and injuring 70 others.

“Why is this still happening?” she asked. “That was so many years ago."

Mayor Jim Kenney expressed the same to reporters on Wednesday night: "It's disgusting. We have to do something about it."

When gunfire began in the late afternoon, officers at the scene were told to stay back after at least two officers became trapped inside the home with the shooter, according to scanner audio.

“We are pinned down in the second floor with three individuals handcuffed,” one officer said calmly amidst the chaotic calls. “You can hear the male moving down stairs on the first floor.”

During another round of gunfire, one officer can be heard saying, "The male is reloading, the male is reloading, shots fired inside."

Another officer says, “That male has a long gun! That male has a long gun!”

This is the second major police shooting this week. Three California Highway Patrol officers were shot, one fatally, on Monday after a motorist opened fire during a traffic stop near Interstate 215 in Riverside.

Contributing: The Associated Press