A suspect is in custody in Philadelphia after an hourslong standoff and shootout that left six officers shot and another injured in a related vehicle crash, authorities said. Two officers and three other people who had been trapped in the building with the shooter were freed after several hours.

CBS Philadelphia says the suspect's lawyer told the station the suspect is 36-year-old Maurice Hill, though police haven't released his name. The alleged gunman surrendered shortly after midnight. Philadelphia Police Commissioner Richard Ross told reporters it was teargas that got the suspect to give up.

Johnson said Hill called him to the scene of the standoff while he was barricaded inside. "Maurice called me in a panic, obviously," Johnson told CBS Philadelphia. "He did not want this to end violently and he really was sort of taking an opportunity to speak his peace. I told him, 'You gotta surrender, man."'

Hill wasn't injured in the shootout, according to the attorney, Shaka Johnson, who added that Hill was brought to a hospital to be checked out, then released with officers surrounding him overnight. Charges haven't been announced.

CBS News has learned Hill has a long criminal history.

Police had initially responded around 5 p.m. on a narcotics warrant and things "went awry almost immediately," Ross said. 

The commissioner said at a nighttime press conference that police were trying to communicate with a "single male" suspect. Police spokesperson Eric Gripp tweeted earlier that police are "imploring him to surrender and avoid further injuries."

Gripp tweeted that children from nearby day care centers were evacuated.

Gripp said the officers were transported to local hospitals with non life-threatening injuries. Philadelphia police said at 11 p.m. that all the officers who were shot had been released from the hospital. One officer who was injured in a vehicle crash related to the incident remained in the hospital. 

Four women who were escorted from the Nicetown-Tioga neighborhood told CBS Philadelphia they were on the second floor of the building with the suspect. "I thank God for these cops," one woman said. Police urged residents to avoid the area.

Sources told CBS Philadelphia it appeared the suspect live-streamed at least part of the shootout. At least one male suspect was believed to be barricaded inside a building, CBS Philadelphia reported.

At least one officer was shot in the head, one was shot in the leg and another in the hand. It's unclear where the other officers were shot. Several of the officers shot were taken to Temple University Hospital. The university said the Health Sciences Center had been on lockdown for several hours, but it was lifted by 7 p.m.

"Seek shelter. Secure doors. Be silent. Be still. Police are responding," the university tweeted earlier.

Police asked news helicopters to avoid the area, tweeting that they were hindering police activity.