This article is more than
8 year oldHe told a memorial service the US must "try to find some meaning amidst our sorrow" and the nation could unite.
Ex-President George W Bush, a Texan, praised the police: "Their courage is our protection and shield."
Mr Obama's trip comes amid mounting racial tension across the country.
Micah Xavier Johnson, 25, opened fire at a protest held over the recent police shootings of Philando Castile in Minnesota and Alton Sterling in Louisiana.
Before he was killed by police, he said he was angry about the shootings.
Protests over excessive police force against African Americans have been held in cities across the US.
But speaking at Morton H Meyerson Symphony Center in Dallas on Tuesday, Mr Obama urged the country not to despair.
Americans are struggling with what has happened in the past week, he said, and events appeared to have revealed "the deepest fault line of our democracy".
"I'm here to say we must reject such despair. I'm here to insist that we are not as divided as we seem."
Dallas police chief scarred by tragedy
US police: 'We are not punching bags'
The service featured five portraits of the officers and five empty chairs.
Dallas Mayor Mike Rawlings spoke first and said: "The soul of our city was pierced."
First Lady Michelle Obama, Vice President Joe Biden and his wife, Jill, will also meet privately with the families of the victims on Wednesday.
Dallas police have ramped up security ahead of the president's visit, enlisting help from the Arlington Police Department to work with Secret Security.
The US has been on edge in the wake of the recent string of violence, with protests over police reform and race relations roiling across the country.
Mr Obama and Mr Biden on Monday met with law enforcement officials to discuss police reform and how to repair relations between police officers and the communities they protect.
The president, who cut short a trip to Europe over the recent violence, is expected to host a similar meeting on Wednesday in Dallas with law enforcement as well as local leaders and activists.
Newer articles