The man accused of opening fire on Philadelphia police officers, wounding six and triggering an hourslong standoff that stretched into the night, has been arrested at least a dozen times since turning 18 -- a rap sheet the city's top cop described as an "extensive" criminal history.

With his hands in the air and a police light illuminating his every movement, alleged gunman Maurice Hill, 36, surrendered to authorities just after midnight Thursday, exiting the north Philadelphia neighborhood home he'd barricaded himself in.

Philadelphia Police Commissioner Richard Ross, who said he spent hours Wednesday negotiating with Hill over the phone, said the situation that unfolded "could have been far worse."

“I am surprised he came out because he was indicating to some that he wasn’t going to do that and that he was not going back,” to prison, Ross told reporters early Thursday regarding some of Hill's alleged statements. “Many of you have found out about his history. It’s very significant. In fact, he told me on the phone, he used the word ‘extensive,’ he had an extensive criminal history and that he knew the system. This is why he was making the outlandish demands he was making.”

PHILADELPHIA POLICE PELTED WITH OBJECTS, TAUNTED DURING HARROWING SHOOTOUT, STANDOFF: REPORTS

Court documents obtained by FOX29 show Hill's lengthy criminal history, including a least a dozen arrests since he turned 18. The 36-year-old has been in and out of prison since 2002 after convictions for such crimes as illegal possession of guns and aggravated assault, according to the documents obtained by FOX29.

At a noon news conference on Thursday, Philadelphia District Attorney Larry Krasner said that Hill "should not have been on the streets," but that law enforcement officials did not have a "crystal ball" to predict his behavior.

Krasner told reporters that Hill has not yet been charged, but may face numerous counts of attempted murder and aggravated assault in addition to "likely drug charges."

"There are more than enough charges, so Mr. Maurice Hill may never exit jail," he said.

Krasner said Hill has an extensive criminal history, including charges involving drugs, guns, and robbery. He added that Hill fired more than 100 rounds during the standoff, and credited authorities with "brilliant policing and maybe a little bit of a miracle" for bringing it to a close.

In 2013, Hill was convicted of perjury and was sentenced to seven months of probation. Records obtained by FOX29 also showed dozens of serious charges over the years that were later withdrawn in court.

Hill also spent time in federal prison, pleading guilty to federal firearms violations in 2008 after he was caught with a Smith & Wesson .357 and a Taurus PT .45 semiautomatic, according to court records obtained by the Philadelphia Inquirer. Prior felony convictions should have kept him from owning those weapons, and a federal judge sentenced him to four years and seven months in prison, the Inquirer reported.

Hill’s former attorney Shaka Johnson, who represented the 36-year-old in a number of previous cases over the past five years that were mostly of a drug-related nature, told FOX29 he answered the phone at 8:30 p.m. on Wednesday and heard Hill on the other end. Johnson said early Thursday that Hill’s first words on the phone were, “I need help.”

“They’re going to kill me. They’re going to kill me,” Johnson recalled Hill saying over the phone.

Johnson, who is a former SWAT officer, said his former client was concerned about his own safety, but also about the wellbeing of his family -- including a newborn daughter. Johnson said the police commissioner gave him 30 minutes to convince his former client to surrender peacefully.

“Mr. Hill and I talked about this. They don’t typically, in scenarios like this, take black defendants into custody. This is what he and I talked about on the phone,” Johnson told FOX29. “I said, ‘My man, this is looking pretty grave for you. The world is watching. That may be one of the things giving police some pause because the world is watching. Use this time wisely.’”

PHILADELPHIA STANDOFF: POLICE DISPATCH AUDIO REVEALS TENSE MOMENTS DURING HOURS-LONG ORDEAL

The shooting started around 4:30 p.m. Wednesday after officers had entered a home to serve a narcotics warrant. The gunman and police traded shots for hours.

Six officers were shot, but have been released from hospitals. Two officers had been trapped in the house during the standoff but were safely evacuated. Ross said Thursday morning he does not believe the gunman knew two police officers were trapped upstairs in the home along with three civilians.

In addition to the phone call with the attorney, the city's top cop said that the tear gas ultimately caused the gunman to come out early Thursday. The gunman was taken to a hospital for evaluation and then placed into custody.

CLICK HERE FOR THE FOX NEWS APP

The shooting caused Temple University to lock down part of its campus, and several children and staff members were trapped for some time in a nearby daycare.

President Trump, who was briefed on the shooting, tweeted Thursday morning the shooter "should have never been on the streets."

"He had a long and very dangerous criminal record. Looked like he was having a good time after his capture, and after wounding so many police," the president said. "Long sentence - must get much tougher on street crime!"

Fox News' Danielle Wallace and Vandana Rambaran and The Associated Press contributed to this report.