A crazed gunman armed with an automatic weapon and a shotgun fired on officers outside Dallas Police Headquarters early Saturday morning before being shot by a police sniper following an hours-long standoff.

Authorities later confirmed the suspect was dead.

Dallas Police Chief David Brown said at a press conference that the gunman-- who self-identified as being James Boulware, though police could not confirm that identity as of Saturday evening-- ranted in a 911 call after the attack about killing cops and came within seconds of doing so in the case of several officers in the line fire.

“We barely survived the intent of this suspect,” Brown said

He said it was extremely fortunate no officers were hurt.

“Some officers say we were lucky, I believe we’re blessed that our officers survived this ordeal,” the chief told reporters.

Investigators found a package containing pipe bombs near the headquarters building and the suspect told police he had C-4 explosives in his armored van, Brown said. The package exploded as an Explosive Ordinance Robot picked it up. “Lots of shrapnel was included in the pipe bombs that exploded-- screws, nails,” a police spokesman tweeted.

Two pipe bombs were also found in the van after the suspect was shot. When police detonated those devices, the gunman’s van caught fire and ammunition rounds went off inside.  

Brown described a harrowing scene at police headquarters when the gunman pulled up around 12:30 a.m. and began firing, first with an assault rifle and then with a shotgun.

Bullets struck police squad cars, the inside of the building’s lobby and a second floor office. Brown said one officer avoided getting shot because he had just left his desk to get a soda.

“This suspect meant to kill officers and took time to discharge that weapon multiple times to accomplish (his) wanting to harm our officers,” Brown said.

While police would not identify the shooter, he reportedly was a man who was involved in a custody fight, who was arrested in May 2013 on charges of choking the child's mother, Fox4News.com reported.

The man reportedly made threats against the judge in the case.

Jim Boulware told Fox4News.com that the shooter was his son, James, and that he knew his son had acquired a number of firearms but did not know how he came to possess explosives, the Dallas news station reported.

Police initially reported multiple gunmen, perhaps as many as four. Brown said detectives now believe the suspect acted alone. He said there was confusion at first because the suspect shot at officers from different locations, giving the impression that others were involved.

As officers returned fire, the gunman fled in his vehicle, which appeared to have gun portals in the sides. The vehicle rammed a police cruiser during the getaway.

Officers chased the suspect 11 miles to the parking lot of a Jack in the Box in Hutchins near I-45. There police exchanged more gunfire with the suspect as officers surrounded the vehicle.

Brown said during the stand-off the suspect called 911 and in a nearly five minute call ranted angrily about wanting to commit violence against police officers.

“It was very high pitch anger towards our police department, police officers,” Brown said.

He said the rant was about how police had caused the suspect to lose custody of his child and about how police had accused him of “being a terrorist.”

Brown said the man was not on any terrorism watch list and the shooting did not appear to be terrorism-related.

Brown said eventually a SWAT team was brought in to negotiate with the man, using the phone number from the 911 call. The gunman told police that he was injured, but authorities could not confirm any injuries, Fox4News.com reported.

Brown said that during the “on-and-off” negotiations a police sniper shot out the engine block with a .50 caliber bullet to disable the vehicle.

He said at 5:07 a.m., more than 4 hours into the stand-off, shot the suspect through the front windshield of the van by a police sniper. 

“They made the call and I believe it was the right call to take the correct action to stop his violence,” Brown said.

The chief said the bomb robot was being used to confirm he was dead. He said the robot was deployed out of fear the van may be rigged with explosives. He said police bomb technicians wanted to make sure the vehicle was not booby-trapped.

The suspect gave a name to police, identifying himself as James Boulware. “This is the name given, however it has not been confirmed that this is the person we are talking to,” Brown told reporters as the negotiations were taking place.

He said the suspect had three family violence cases against him and “some kind of custody issue.” He said the man had threatened judges handling his cases, but had not acted on those threats.

“His social media footprint is awfully concerning, but there’s no indication that he was planning this type of assault on a police facility,” Brown said.

Police evacuated residents near police headquarters for several hours. A suspicious briefcase found in a dumpster near a police substation was not a bomb, police said.

Ladarrick Alexander and his fiancée, Laquita Davis, were driving back toward the police station to their nearby apartment when they heard 15 to 20 gunshots in quick succession.

Seconds later, police could be seen swarming an unmarked van that appeared to have crashed into a police car, they said.

They turned around and were parked outside the police perimeter about two blocks away, where they heard the sound of one detonation at about 4:30 am and smoke coming up in the air.

Police headquarters is in a former warehouse district where a boutique hotel and several new apartment buildings have been opened.

"We don't see too much going around here at all," Alexander said.

Click for more from Fox4News.com

The Associated Press contributed to this report.