The gunman killed in a stand-off with Dallas police said he was upset about the police shootings of black people and wanted to kill white officers, the city's police chief has said.
The suspect told police that he was working alone, Police Chief David Brown told reporters.
Five Dallas police officers were killed and seven wounded by gunmen during protests against the shooting of black men by police, authorities say.
Three people are in custody.
Mr Brown said the suspect had been killed when police used explosives placed by a robot to end a tense stand-off in a building where he was holed up.
He said the gunman had told a negotiator that he was "upset about Black Lives Matter [protest movement], he said he was upset about the recent police shootings. The suspect said he was upset at white people. The suspect stated that he wanted to kill white people, especially white officers."
Mr Brown added: "He said he was not affiliated with any groups, and he did this alone."
Gunfire broke out at around 20:45 local time on Thursday (01:45 GMT Friday) as demonstrators marched through the city.
The protests came after this week's deaths of Philando Castile in Minnesota and Alton Sterling in Louisiana.
President Barack Obama, who is attending a Nato summit in Poland, called it a "vicious, calculated and despicable attack on law enforcement". He said the entire city of Dallas was grieving and the "tight-knit US police community feels this loss to their core".
Speaking earlier, Mr Brown said the suspects were believed to have been working together, using rifles to carry out attacks while the protest rally was drawing to a close.
Two snipers had fired from "elevated positions", shooting some officers in the back, he said.
"We believe that these suspects were positioning themselves in a way to triangulate on these officers from two different perches… and planned to injure and kill as many law enforcement officers as they could," Mr Brown said.
The Dallas attack marks the deadliest day for US law enforcement officers since the 9/11 attacks in 2001.
Officers later surrounded a car park near El Centro College where the stand-off with the suspect took place.
Dallas Mayor Mike Rawlings said that two civilians, one man and one woman, were also injured in the shootings.
He told the NBC Today programme that the suspects in custody so far were not co-operating and were "tight-lipped".