One suspect is in custody after a shootout with police, while a person of interest turned himself in, Dallas police tweeted.
Gunfire broke out as demonstrators marched through the city.
The protests were sparked by the deaths of Philando Castile in Minnesota and Alton Sterling in Louisiana.
Dallas Police Chief David Brown said 11 officers were shot “ambush style” by snipers, killing three. Police later said a fourth had died.
“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,” he said.
One of the march’s organisers, Reverend Jeff Hood, saw people scramble for cover as gunfire rang out.
“I ran away from the shots trying to get people off the streets and I was grabbing myself to see if I was shot,” he told the Dallas Morning News.
Bomb teams are investigating a suspicious device left at the scene of the shootout with a suspect.
Police issued a photo of one of the suspects with a rifle slung over his shoulder. It is not clear if he was involved in the shootout or had handed himself in.
The Mayor of Dallas, Mike Rawlings, said it was a “heart-breaking moment for the city”.
The Dallas protests were among several held across the US over the police use of lethal force against African Americans.
Philando Castile was shot dead at a traffic stop in St Paul on Wednesday, while Alton Sterling killed by police a day earlier in Baton Rouge.
Both incidents were captured on video, reigniting what has become a national debate.
US President Barack Obama said “all fair-minded people should be concerned” about the frequent police killings of black Americans.
Pointing to statistics showing African-American citizens are far more likely to be shot by police by whites, Mr Obama called on law enforcement to root out internal bias.
“When incidents like this occur, there’s a big chunk of our fellow citizenry that feels as if it’s because of the colour of their skin, they are not being treated the same,” he said. “And that hurts.”