The suspect believed to have ambushed Dallas officers during a protest against US police brutality, leaving five dead and seven others wounded, told negotiators he wanted to kill white cops, the city's police chief said Friday.
Two civilians were also shot and wounded in the chaotic fray late Thursday in the sprawling Texas city, one of many cities across the United States where protests had erupted over the fatal police shootings of two black men earlier this week.
President Barack Obama called the Dallas sniper-style ambush a "vicious, calculated and despicable attack on law enforcement" and pledged that those responsible would be held accountable.
The shootings sparked chaotic scenes of people running for their lives during a march by several hundred demonstrators in the city of roughly 1.2 million people.
One witness at the rally spoke of "complete pandemonium," in an area close to the site where president John F Kennedy was killed in 1963.
The primary suspect was killed in a tense showdown with police in a parking garage, authorities confirmed.
An unspecified number of suspects in custody, including one black woman, were "not being real cooperative," Dallas Mayor Mike Rawlings said. Earlier, officials said three people had been detained.
It was the single biggest loss of life for law enforcement in America since the September 11, 2001 attacks, and appeared likely to further strain already tense race relations in the country.
"Dallas officers are hurting. We are heartbroken. There are no words to describe the atrocity that occurred to our city," city police chief David Brown told reporters.
"This must stop -- this divisiveness between our police and our citizens."
Rawlings and Brown explained that police used an explosive device sent in by robot during the standoff with the suspect, who he only described as "male."
The suspect was killed in the explosion, Brown said, but before that, he revealed some of his possible motive to negotiators.
"He said he was upset about the recent police shootings. The suspect said he was upset at white people. The suspect stated he wanted to kill white people, especially white officers," Brown said.
The gunman said he was not affiliated with any organized groups.
"He was saying he was going to take everybody out. He threatened other bombs and we felt that was the safest way to get in and it was," Rawlings said.
Sweeps have been completed and no explosives were found, Dallas police major Max Geron said on Twitter.
One witness at the Dallas rally spoke of "complete pandemonium," in an area close to the site where president John F Kennedy was killed in 1963.
"There was blacks, whites, Latinos, everybody. There was a mixed community here protesting. And this just came out of nowhere," Cory Hughes, a protest organizer, told CNN.
"I'm still kind of startled, shaken up," Hughes said. "It's almost like the gunshots were coming at us. It was complete pandemonium... It's bananas."
As the rally was winding up, shots rang out around 9:00 pm (0200 GMT Friday), causing panic among the protesters, who scrambled to take cover.
Brown initially said police believed at least two snipers had shot at police ambush-style from high vantage points. It was unclear Friday morning if authorities still believed there had been more than one shooter.
Earlier, Brown said three suspects had been taken into custody -- a woman and two men found with camouflage bags in a car.
Dramatic video of the shooting emerged from witnesses, who posted the footage online. Bursts of gunfire and police sirens could be heard in the videos.
In one video, posted by Twitter user @allisongriz, a witness can be heard saying: "Oh, my God. There are people laying on the ground. I hope they're just hiding."
Parts of downtown Dallas were closed off for hours, with no bus or rail service and flight restrictions in effect.
Outside Parkland Hospital, police saluted their fellow officers who lost their lives or were wounded in the shooting. Other people later joined the officers for an impromptu vigil.
The Dallas protest was one of several nationwide over the deaths of Alton Sterling in Louisiana and Philando Castile in Minnesota that prompted Obama to make an emotional appeal for urgent police reform.
Thousands marched in Atlanta, Chicago, Los Angeles, Saint Paul, Washington and other cities late Thursday, with more than 1,000 protesters gathering in New York's Times Square.
Obama issued an emotional appeal for unity, but also made it clear that violence against police had "no possible justification."
"There is no contradiction between us supporting law enforcement... and also saying that there are problems across our criminal justice system, there are biases -- some conscious and unconscious -- that have to be rooted out," Obama said.
"So when people say "Black Lives Matter," that doesn't mean blue lives don't matter -- it just means all lives matter," he said in Poland, where he was attending a NATO summit.
Rawlings, the Dallas mayor, called it a "heartbreaking morning."
"We as a city, we as a country, must come together, lock arms and heal the wounds that we all feel from time to time. Words matter. Leadership matters at this time," he said.