One or more snipers opened fire ambush-style, killing five officers and wounding nine people, including seven cops. The violence erupted at an otherwise peaceful rally attended by several hundred people in tribute to the black men slain earlier this week, one in Louisiana and the other in Minnesota.
A suspect died in a showdown with police at a downtown garage while officials locked down Dallas, America's ninth largest city. Here is a timeline of events.
Tuesday: Fuse is lit in Louisiana
On Tuesday, Alton Sterling, 37, is wrestled to the ground and shot at point-blank range as he sells CDs in front of a store in Baton Rouge. A large pool of blood forms on his chest.
Videos of the father of five being killed triggers protests and outrage across the country. The U.S. is already tense as a policeman is due to stand trial Thursday in Baltimore over the April 2015 death of Freddie Gray, a black man whose spine was broken in the back of a police van.
A federal civil rights investigation is quickly launched into Sterling's death.
Wednesday: Dying moments livestreamed from Minnesota
On Wednesday, Philando Castile, 32, is shot at close range by a policeman in the Minneapolis suburb of Falcon Heights after being pulled over for a broken taillight.
Castile had informed the officer he was carrying a gun and had a permit to do so, but was shot as he reached for his driver's license and car registration.
Castile's girlfriend Diamond Reynolds livestreams the aftermath of the shooting, which shows an officer pointing his gun at her through the window as her four-year-old daughter sits in the back of the car.
The video, watched millions of times on social media, shows Castile bleeding profusely, moaning and gasping for air. Reynolds says the Asian male officer made conflicting demands of Castile, who had no police record, ordering both that Castile keep his hands in the air and that he identify himself.
Castile's mother Valerie says: "Our black children are on the endangered species list."
Thursday: Protests erupt across the nation
The two killings prompt thousands to march in Atlanta, Chicago, Dallas, Los Angeles, Saint Paul and Washington late Thursday, while more than 1,000 people protest in New York's Time Square.
Obama, the first black US president, says it is clear the shootings are not "isolated incidents."
But he also adds: "Just because we say black lives matter doesn't mean blue lives don't matter."
At least 123 black people have been shot dead by police in the United States this year, half of last year's toll of 258, according to Washington Post data.
Speaking in Warsaw, Obama denounces "a vicious, calculated and despicable attack on law enforcement."
Friday: Suspect identified
The man suspected of opening fire on Dallas police officers is identified as 25-year-old Texas resident Micah Johnson, US media report. He was killed in a tense showdown with police after the shootings, which also left two civilians wounded.
Related news:
> Dallas remains shaken by police killings
> U.S. military veteran believed to be lone gunman in Dallas police ambush
> Four officers killed, seven wounded in Dallas shooting protest