A US army veteran killed by Dallas police after the sniper slayings of five officers amassed a personal arsenal at his suburban home, including bomb-making materials, bulletproof vests, rifles, ammunition and a journal of combat tactics, authorities say.
The man identified as 25-year-old Micah Xavier Johnson told authorities that he was upset about the police shootings of two black men earlier this week and wanted to exterminate whites, "especially white officers", officials said.
He was killed by a robot-delivered bomb after the shootings. In all, 12 officers were shot.
The shooting sent swarms of protesters running in panic in the streets as police officers came under fire.
The shootings, the latest major gun violence to rock the United States, took place toward the end of a march protesting incidents earlier in the week in Louisiana and Minnesota in which police fatally shot black men in confrontations whose bloody aftermath was caught on video.
The Dallas shootings came during a week of heightened emotions over police use of force against black suspects and raised fears that others might seek to retaliate against police.
"This was a well-planned, well-thought-out, evil tragedy by these suspects. And we won't rest until we bring everyone involved to justice," Dallas Police Chief David Brown said on Friday.
"We are determined to not let this person steal this democracy from us."
During lengthy negotiations with police, the gunman said "the end is coming," Mr Brown told reporters.
"He said he was upset about the recent police shootings," said Mr Brown, who is black.
"The suspect said he was upset at white people. The suspect stated that he wanted to kill white people, especially white officers."
Authorities said that the gunman fired at least some of the shots in the attack but have not ruled out that other shooters were involved.
Details on how the shootings unfolded remained unclear.
It also was not clear how one person could have shot so many officers, though video of the attack taken by a witness shows a gunman carrying an assault-style weapon and carrying large amounts of ammunition.
The US Army said Johnson had served as a private first class in the Army Reserve, made up of part-time soldiers, and was deployed to Afghanistan from November 2013 to July 2014.
It said Johnson served from March 2009 to April 2015 and was a carpentry and masonry specialist with the 420th Engineering Brigade based in Texas.
In Poland for a NATO summit, President Barack Obama called the shooting "a vicious, calculated and despicable attack on law enforcement."
Mr Obama, who has been stymied by the Republican-led Congress in his bid for new gun control laws, added, "We also know when people are armed with powerful weapons unfortunately it makes attacks like these more deadly and more tragic."
A string of killings of black men and boys by police in cities including Ferguson, Missouri, New York, Baltimore, Chicago, Cleveland, Tulsa, Oklahoma and North Charleston, South Carolina have given rise to the Black Lives Matter movement against excessive police force.
The killings have spurred almost two years of periodic and largely peaceful street protests.
Police believed during the shooting that they were under attack by multiple gunmen using high-powered rifles at ground level and on rooftops.
Police said they were questioning two occupants of a Mercedes they had pulled over after seeing a man throwing a camouflage bag inside the back of the vehicle, which then sped off on a downtown street.
A woman was also taken into custody near the garage where the standoff took place.
A Twitter account describing itself as representing the Black Lives Matter movement sent the message: "Black Lives Matter advocates dignity, justice and freedom. Not murder."
US Attorney General Loretta Lynch said the Justice Department would assist in the investigation into the shooting.
"Do not let this week precipitate a new normal in this country," Ms Lynch told reporters in Washington.