BANGOR, Maine — A 43-year-old man in a Park Street residence who fired 70 or more rounds from a gun was taken into custody unharmed early Thursday afternoon, according to police.

Perrin Oliver of Detroit, Mich., was arrested and charged with Class B reckless conduct with a firearm and Class C criminal threatening with a dangerous weapon, according to a deputy at the Penobscot County Jail, where Oliver is being held. Both charges are felonies.

Bangor police received a call at 8:30 a.m. reporting a man firing shots out of a second-floor apartment window in a building at 47 Park St., said Bangor police Sgt. Paul Edwards after the man was in custody.

Oliver was residing in Bangor, according to Edwards.

Police created a perimeter several blocks wide because the man was shooting out of his window. Residents in the building he was in and residents in surrounding downtown buildings were evacuated, Edwards said.

Police negotiated for two hours and finally used tear gas to get him out of the building.

“No officers injured at this point. We’re happy that it successfully ended where no one was hurt,” said Edwards. “The suspect is in fact alive and not hurt.”

Edwards said police interviewed a woman and a small child at the police station, and they brought police back to the residence where the shooter was staying. The woman and child fled to the police station after Oliver had fire his gun.

A handgun was taken into evidence and the department’s Evidence Response Team is still investigating the scene with the Criminal Investigations Division, said Edwards.

“The suspect that’s in custody did, in fact, shoot 70 or more shots at different periods — four or five at a time. Every few minutes he would shoot four to five bullets,” said Edwards. “Some of those appeared [to be] shot out the window. That’s why people were diverted.”

The Fourth of July Parade that typically proceeds through the area police taped off was rerouted down Water Street. Police used a robot during the standoff.

The last rounds heard were from police firing tear gas into the building, Edwards said.

“Watching these guys operate was absolutely incredible,” Edwards said of the department’s Special Response Team. “My hat’s off to them for saving this man’s life.”

Oliver was the only one shooting, he said. The man was taken to the Penobscot County Jail in Bangor.

Gov. Paul LePage, who was walking in the parade, heard about the standoff.

“It’s unfortunate, but we have bad people in the world,” LePage said. “Thank God we have police.”

Blaine Richardson, R-Belfast, a candidate for the U.S. 2nd Congressional District, was also in the parade.

“I have faith in the Bangor Police Department,” Richardson said before the standoff ended. “I can say I am sure that they will have it cleaned up and taken care of in no time.”

The Class B crime carries a maximum prison sentence of up to 10 years and a fine of up to $20,000. The Class C crime carries a maximum prison sentence of five years and a fine of up to $5,000.

BDN reporter Nick Sambides contributed to this report.

Watch for updates.