In the traumatic hours after a deadly ambush of Dallas police, and outpouring of grief and sympathy flooded the Dallas police station. (Dalton Bennett/The Washington Post)

DALLAS — President Obama on Saturday sought to calm a country riven by grief and anger in the wake of the fatal shooting of five police officers here and recent high-profile deaths at the hands of officers elsewhere. His comments came as Dallas continued to reel from the rampage while protests over how police use deadly force continued in cities across the country.

In Dallas, the downtown area where a lone attacker killed the officers in a rampage authorities said was fueled by racial animus remained quiet on Saturday while investigators pored over the crime scene and the gunman’s background. But in cities around the country, demonstrations over police shootings had continued the night before, some of them becoming quite heated while others were infused with sober reflection over the carnage in Dallas.

“As painful as this week has been, I firmly believe that America is not as divided as some have suggested,” President Obama said Saturday while in Poland for a NATO summit. “Americans of all races and all backgrounds are rightly outraged by the inexcusable attacks on police, whether it’s in Dallas or any place else.”

At a news conference at the NATO summit in Poland, President Obama talked about the ambush that left five Dallas police officers dead on Thursday during a demonstration. Obama plans to visit Dallas early next week. (Reuters)

Police say the attacker in Dallas — identified as Micah Xavier Johnson, a black 25-year-old from a nearby suburb — told them he was angry over police killings of black men, an issue that surged back into the news this week after these recent incidents in Baton Rouge, La., and outside St. Paul, Minn. Before authorities used a bomb to kill Johnson, they say he told police he wanted to kill white officers.

“The suspect said he was upset about black lives matter,” David Brown, the Dallas police chief, said of the attacker’s comments. “He said he was upset about the recent police shootings. The suspect said he was upset at white people. The suspect stated he wanted to kill white people, especially white officers.”

[The victims of the Dallas protest shooting]

Brown said the attacker’s comments were made during a prolonged, and at times violent, standoff that followed the brutal shooting rampage Thursday night during a peaceful protest over police shootings.

This attack fused two topics that have roiled the country in recent years — mass shootings and outrage over how police use force — bringing them together in a horrific way decried by law enforcement officials around the country and activists protesting police shootings alike.

Obama said “Americans of all races and all backgrounds are also rightly saddened and angered” over the deaths this week of black men fatally shot by police officers in Louisiana and Minnesota. He also tied the mass shooting here to some of the rampages that have claimed dozens of lives since last year, invoking the rampages at a historic black church in Charleston, S.C.; a gay club in Orlando; and an office party in San Bernardino, Calif.

“We cannot let the actions of a few define all of us,” Obama said. “The demented individual who carried out those attacks in Dallas, he’s no more representative of African Americans than the shooter in Charleston was representative of white Americans, or the shooter in Orlando, or San Bernardino, were representative of Muslim Americans,” Obama said. “They don’t speak for us. That’s not who we are.”

Across the country on Friday, activists and demonstrators continued to do what they have done on other nights this week, taking to the streets for vigils and protests — large and small, some calm and others more animated, a series of events echoing those that followed cases where black people died during encounters with police in Ferguson, Mo., Baltimore and New York City.

In Dallas, details of the shooting — and the gunman who authorities say injured seven officers and two civilians in addition to killing five officers — were still coming into focus Saturday, as investigators sought to piece together what happened before and during the attack.

Around the stretch of downtown where the shooting occurred, signs of violence still littered the streets. Police officers monitoring the perimeter of the crime scene mixed Saturday with reporters and occasional people walking their dogs in Belo Garden Park. Shattered glass remained on the ground along Elm Street. A handful of FBI investigators, wearing gloves and blue booties on their feet, came and went from the scene.

A makeshift memorial of flowers sat at the base of three flagpoles not far from where the shooting began. Someone had tied a red T-shirt tied around one of the poles with the words, “Police Lives Matter.”

A woman knelt nearby, her eyes shut tight, praying. A mile south at the Dallas Police Headquarters, a memorial to the five fallen officers had continued to grow. Flowers, balloons and ribbons covered a Dallas police cruiser and a Dallas Area Rapid Transit car. Hundreds of people had handwritten left notes on cards stamped with the phrase, “We unite.” “Prayers for you and for all law enforcement,” a woman named Rita had written. “We will forever be grateful for all y’all do,” a man named Jeremiah had written.

“Texans have always shown trademark resilience, which is needed now more than ever,” Gov. Greg Abbott (R) said.

Protests took place in cities across the country on Friday to condemn police brutality. In Atlanta, some demonstrators blocked a highway and in Phoenix police used tear gas and pepper spray to break up a protest. People in Dallas gathered outside of the police headquarters to remember the five officers killed in an ambush. (Claritza Jimenez/The Washington Post)

Two days earlier, a calm protest over police shootings — one of many that occurred Thursday night across the country — was suddenly riven by violence when a gunman began firing at police assembled for the demonstration.

Dallas Mayor Michael S. Rawlings said that Johnson “was a mobile shooter that had written manifestos on how to shoot and move, shoot and move, and he did that.”

Because Johnson moved through a part of downtown Dallas on Thursday night, firing at officers from multiple locations, police had said after the attack that they believed “two snipers” were firing “from elevated positions.” A day later, Rawlings and other officials said they now believed Johnson was the lone attacker.

[Dallas shooter ‘was a good kid’, says neighbor. ‘I believe he just snapped.’]

“He did his damage, but we did our damage to him as well,” Rawlings said. “And we believe now that the city is safe and that the suspect is dead and we can move on to healing.”

Police had also said they took three other people into custody — two men and a woman — but they have offered no word on if these people were still being held or why. A Dallas police spokeswoman did not respond to a request for comment.

The chilling nature and deadly scale of the attack sent shock waves through the country, a third day of violence viewed through graphic videos, first from Baton Rouge, then from a suburb of St. Paul, Minn., that showed the shootings or the aftermath.

Fear rippled through law enforcement nationwide as police chiefs from Washington to Los Angeles ordered patrol officers to go out in pairs for safety. Officers were also shot in Missouri and Georgia in separate incidents, leaving one in critical condition.

[A peaceful protest gives way to an urban war zone]

And investigators in Tennessee said they believed a man who opened fire on a parkway before exchanging gunfire with police may have been motivated by concerns over encounters involving police and black Americans. The shooting spree, which occurred before the Dallas attack but after anger was boiling over from the Louisiana and Minnesota shootings, left one woman dead and two people injured. A Bristol, Tenn., police officer was also shot in the leg before officers shot and wounded the attacker.

The bloodshed in Dallas marked the deadliest single day for the nation’s police since the Sept. 11, 2001, terrorist attacks, with five officers killed and seven others injured.

Gunfire began here around 9 p.m. Thursday, and while people scrambled for cover and sheltered in place and police tried to figure out what they were confronting, some people in the area posted videos to social media showing the killings in real time. One video showed a person with an assault-style rifle shooting a police officer in the back at point-blank range.

Johnson at one point fled to a college building downtown, authorities say. For hours after the initial assault, police were locked in a standoff with the shooter, exchanging gunfire and negotiating with him. During these discussions, he told police they would eventually find explosives he planted, but as of Saturday, authorities have not said they found any devices.

At his home, they did find the well-known tools of the mass murderer: bomb-making and ballistic materials, more guns and ammunition. They also found “a personal journal of combat tactics,” which detectives are still analyzing, the Dallas police said Friday.

[Dallas Police Chief David Brown lost his son, former partner and brother to violence]

Brown said police placed an explosive device on their bomb robot and used it to kill Johnson. Rawlings said the robot was the same kind typically used to detonate and defuse bombs, and in this case was used to place C-4 explosives and detonate them.

Police said they believed Johnson was a “loner” from Mesquite, a Dallas suburb. He had no criminal record before the attack.

Avis Blanton, who lived next door to Micah Xavier Johnson and his family for more than 12 years in Mesquite, said Johnson “was a good kid. He was truly, truly good.” In an interview Friday, she said she believes Johnson “just snapped.”

“Black folks are tired,” Blanton, 43, said. “We are just tired. I am not justifying what he did, but I see why he did it.”

Jim Otwell, who lives in Mesquite, TX, says the last time he spoke to Micah Johnson was in 2015. The Dallas shooter had asked him for help after Johnson said a number of guns were stolen from his home. (Ashleigh Joplin/The Washington Post)

An Army reservist who had deployed to Afghanistan — and, according to the Associated Press, was accused of sexual harassment by a female soldier while there — Johnson killed fellow veterans. Four of the five slain officers had served in the military.

Brent Thompson, 43, was a transit police officer and a newlywed. Patrick Zamarripa, 32, had served three tours in Iraq. Michael Krol, 40, had joined the Dallas police in 2008. Lorne Ahrens, a former semi-pro football player, had been with the department for 14 years. Michael Smith, a father of two, liked to give department stickers to the children at his church.

Outside police headquarters Friday, a steady stream of locals paid their respects, draping flowers and toys across police cars. Gathered in the shade, a band of officers watched quietly. Several had rushed from their homes the night before to try to help. “I pulled on my uniform and came to protect my brothers,” said one officer, who spoke on the condition of anonymity. “I haven’t slept — I can’t. I knew every one of the guys who died.”

[Police nationwide order officers to ride in pairs after Dallas police ambush]

President Obama, who ordered flags flown at half-staff until Tuesday, said he would cut short a trip to Europe and return early so he can visit Dallas next week. Attorney General Loretta E. Lynch vowed that the Justice Department would do anything it could to help with the investigation. Lynch also said she was “heartbroken” by the loss and urged peaceful protesters not to “be discouraged by those who use your lawful actions as cover for their heinous violence.”

Meanwhile, in Dallas — after the shooting, after police dealt with the gunman, after the chaos gave way to grief — Rawlings said he couldn’t shake a memory from those early hours. He remembered the moment he learned that a fifth officer had died.

“We were thinking, when is it going to stop?” he said. “Five officers killed – this just doesn’t happen in the United States of America.”

Dennis reported from Dallas. Wan and Berman reported from Washington. Joel Achenbach, Jamie Thompson, Louisa Loveluck and Keith L. Alexander in Dallas; and Julie Tate, Jennifer Jenkins, Tom Jackman, Peter Hermann, Thomas Gibbons-Neff and Magda Jean-Louis in Washington contributed to this report.

Further reading:

Nation’s officers on edge as deaths in Dallas bring yearly toll among police to 25

‘Vicious’ attack on police in Dallas by black shooter raises pressure on Obama

Bahamas issues travel advisory for the U.S. aimed at interactions with police

[This story has been updated.]