President Barack Obama, speaking at a news conference after participating in a NATO summit in Warsaw, Poland, says that if Americans care about the safety of police officers, they cannot pretend that the country's problems with gun violence are irrel
President Barack Obama, speaking at a news conference after participating in a NATO summit in Warsaw, Poland, says that if Americans care about the safety of police officers, they cannot pretend that the country's problems with gun violence are irrel

WASHINGTON/DALLAS - U.S. President Barack Obama sought Saturday to reassure Americans shaken up by what he acknowledged was a "painful week" following two fatal police shootings of African-Americans and an ambush that left five policemen dead in Dallas.

Obama was speaking at a NATO summit in Warsaw, but he devoted much of his news conference to events back home. The president is cutting his trip to Europe short by one day and will return to Washington Sunday night. He said he planned to travel to Dallas in the coming days at the invitation of Mayor Mike Rawlings.

The city remained on edge Saturday, especially after Dallas police received an anonymous threat against officers across the city. The threat led officials to lock down the headquarters and several blocks surrounding the building as a "precautionary measure," a police statement said.

In Poland, Obama opened his remarks with the aftermath of the Dallas shooting, saying, "I firmly believe America is not as divided as some have suggested." He said the country has a foundation to build on to tackle the very real problems it faces, including tensions between law enforcement and minority communities.

Asked about how he would characterize the Dallas shooter, Obama called him a "demented individual."

WATCH: Dallas Honors Fallen Officers

2446332_1551215464 video player.

The Dallas shooter is not representative of blacks, the president said, just as the man who killed people at a historic African-American church last year in Charleston is not representative of whites, and the Muslim American who killed 49 people at an Orlando nightclub last month is not representative of Muslim Americans.

'Part of the problem'

On the issue of gun violence, in response to a question, Obama said, "I am not going to stop talking about guns, because they are part of the problem."

He said if people care about the safety of police officers, they cannot pretend that the gun issue is irrelevant. He said it would never be possible to stop every violent madman intent on carnage, but the U.S. could make it much harder for them.

He said the scope of gun violence in the United States is unique.

U.S. Army retired Combat Medic Chandler Davis stood in quiet salute for hours at a makeshift memorial outside the Dallas Police Headquarters, in Dallas, Texas, July 9, 2016.

On Saturday, the people of Dallas were working through the emotions of Thursday's violence and trying to make sense of the tragedy, which in addition to the fatalities it caused left seven officers and two civilians injured.

In front of Dallas Police Department headquarters, passers-by offered condolences at two squad cars decked with flowers, children’s toys and notes of sympathy.

Those who came were African-Americans, whites and Latinos, and included many officers mourning the loss of their colleagues.

Dallas Mayor Mike Rawlings visits a makeshift memo
Dallas Mayor Mike Rawlings visits a makeshift memorial of police cars, in honor of the slain Dallas police officers, in front of their headquarters in Dallas, July 9, 2016.

'Support them'

Michael Walton, a Dallas police officer and president of the Dallas Fraternal Order of Police, earlier in the day had visited the injured officers in the hospital.

“They’re going to be OK one day,” Walton said. “We’re just trying to get them through it, support them, let them know that we’re still here for them, and their families, too.”

Recalling the events of Thursday night, “I was ... just in shock,” recalled Terry Mack, an officer with the Dallas transit police, who was off duty but lost one colleague and saw others injured. He said he had worked with them all.

“All of our officers are heroes,” said Dallas police Sergeant Demetrick Pennie, president of the Dallas Fallen Officers Foundation. “While everyone else was running away from the bullets, our officers were running to the bullets."

Karen Copeland came to the memorial site with her daughter Kylie, 5, to try to make sense of images they had seen on television, and “to show her [daughter] that in the midst of it all, there’s still peace and people still have love in their hearts.”

Flags fly at half-staff at a makeshift memorial ne
Flags fly at half-staff at a makeshift memorial near the crime scene two days after a gunman ambushed and killed five police officers at a protest decrying police shootings of black men, in Dallas, July 9, 2016.

Jason Quigley, a sheriff’s department deputy in nearby Denton County, brought his teenage daughter to “understand what we do every day and understand what can happen to us.”

Quigley said he also wanted her to see “how the community supports everybody.”

More than a dozen riders from the Southern Dawgs Motorcycle Club, which includes former police officers, also came to pay their respects.

“The people that were there that night were peaceful, exercising their right to voice their opinion,” said the club’s spokesman, known as Shocker. He said the man who attacked the officers was cowardly.

WATCH: 'I Firmly Believe America is Not as Divided as Some Have Suggested,' Obama Says

2446332_1551212652 video player.

Race relations

Obama spoke at length on race relations, rejecting any suggestion that the country was returning to the strife and urban riots of the 1960s, and noting that police in Dallas kept on protecting protesters even while they were being shot at.

He said the country has made tremendous progress, both in lowering violent crime rates and on achieving racial equality. But, the president added, the legacy of racism endures, and there is much work still to be done.

Obama said that he hoped his daughters, Sasha and Malia, and their children could live in a more just and equal country, but that progress takes time.

Asked about his legacy on race as the first African-American president, Obama said: "We plant seeds. And somebody else maybe sits under the shade of the tree that we planted."

The president left Warsaw after the news conference for Spain, arriving Saturday night. Obama will meet with King Felipe and acting Prime Minister Mariano Rajoy before traveling to a U.S. naval base in Rota, in southern Spain.

U.S. President Barack Obama, left, waves as is wel
U.S. President Barack Obama, left, waves as is welcomed by Spain's King Felipe following his arrival aboard Air Force One at the Torrejon airbase, outside Madrid, Spain, July 9, 2016.

From aboard Air Force One on the flight to Madrid, Obama phoned Texas Governor Greg Abbott to offer his condolences on behalf of the American people, a White House statement said.

Details of attack

Dallas Mayor Rawlings confirmed that the shooting of the officers on Thursday was carried out by a lone gunman, identified as Micah Johnson. The attack, which city officials labeled an "ambush," happened toward the end of a peaceful demonstration against the killing of two black men by police officers in Minnesota and Louisiana earlier in the week.

Jasmine Ruiz writes a note at a makeshift memorial
Jasmine Ruiz writes a note at a makeshift memorial in front of the police department in Dallas, July 9, 2016. Five police officers were killed in a shooting in downtown Dallas on Thursday.

Texas Governor Abbott said law enforcement officers would investigate and determine whether any co-conspirators or other suspects might have helped him. He added, "We need to focus on the imperative of unity: that we unite all citizens of Dallas, all citizens of Texas."

During a search of Johnson's home Friday, Dallas police detectives found bomb-making materials, ballistic vests, rifles, ammunition and a personal journal of combat tactics, the police department said. The gunman was a former Army reservist who served in Afghanistan.  

The attack was the deadliest day for U.S. law enforcement since the terror attacks of September 11, 2001, on the U.S. East Coast.