Police described Thursday night's ambush as carefully planned and executed and had taken three people into custody before a fourth died from what Dallas-based media said was a self-inflicted gunshot after a standoff that extended into Friday morning.
The fourth suspect had exchanged gunfire with police during the standoff at a downtown garage and warned of placing bombs throughout the city. Police have yet to confirm his death.
The attack, which took place as a protest in Dallas was winding up under the watch of officers, was one of the worst mass shootings of police in U.S. history.
White House officials have spoken with Dallas Mayor Mike Rawlings about the shooting that turned the downtown of one of the largest U.S. cities into a sprawling crime scene, unfolding along streets that house major corporations, restaurants and government offices.
President Barack Obama, while in Poland, said he had spoken to Rawlings and expressed his "deepest condolences" on behalf of the American people.
"I believe I speak for every single American when I say that we are horrified over these events and we are united with the people and police department in Dallas," he said.
Obama said the FBI was in contact with the Dallas Police Department and that the federal government would provide any assistance to Dallas as it deals with the incident.
"We still don't know all of the facts. What we do know is that there has been a vicious, calculated and despicable attack on law enforcement," he said.
No specific motive has been given for the shootings at the downtown protest, one of many held in major cities across the United States on Thursday. New York police made more than a dozen arrests on Thursday night, while protesters briefly shut down one of Chicago's main arteries.
Dallas Police Chief David Brown said the shooters, some in elevated positions, used sniper rifles to fire at the officers in what appeared to be a coordinated attack.
"(They were) working together with rifles, triangulating at elevated positions in different points in the downtown area where the march ended up going," Brown told a news conference, adding a civilian was also wounded.
"It has been a devastating night. We are sad to report a fifth officer has died," Dallas police said on Twitter.
Mayor Rawlings advised people to stay away on Friday morning as police combed the area where large areas have been cordoned off and transport halted. Federal authorities also halted commercial air traffic for the area as police helicopters hovered over the scene.
"Our worst nightmare has happened," he said. "It is a heartbreaking moment for the city of Dallas."
Police were conducting bomb sweeps throughout downtown Dallas, where officials said many county offices were to be closed on Friday.
The Dallas-Fort Worth metropolitan area is one of the nation's most populous and is home to more than 7 million people.
The use of force by police against African-Americans in cities from Ferguson, Missouri, to Baltimore and New York has sparked periodic and sometimes violent protests in the past two years and has spawned the Black Lives Matter movement.
Anger has intensified when the officers involved in such incidents have been acquitted in trials or not charged at all.
The shooting happened as otherwise largely peaceful protests unfolded around the United States after the shooting of Philando Castile, 32, by police near St. Paul, Minnesota, late on Wednesday. His girlfriend posted live video on the internet of the bloody scene minutes afterward, which was widely viewed.
The suspect in the standoff had told police "the end is coming" and that more police were going to be hurt and killed. Brown said the suspect also told police "there are bombs all over the place in this garage and downtown".
Police said they were questioning two occupants of a Mercedes they had pulled over after the vehicle sped off on a downtown street with a man who threw a camouflaged bag inside the back of the car. A woman was also taken into custody near the garage where the standoff was taking place.
"We are leaving every motive on the table on why this happened and how this happened," Brown said.
Rawlings visited the wounded at Parkland hospital, the same hospital where President John F. Kennedy was taken after he was shot in Dallas in November 1963.
Outside, officers stood in formation and saluted as bodies of the officers were about to be transported.
One of the officers killed has been identified. He is Brent Thompson, 43, and an officer with Dallas Area Rapid Transit.