President Barack Obama has told a memorial service that the shootings of five Dallas police officers would appear to have exposed "the deepest fault line of our democracy" but that Americans must reject such despair.
He insisted the nation is not as divided as it seems and called on Americans to search for common ground in support of racial equity and justice.
Mr Obama acknowledged Americans are unsettled by another mass shooting on their streets and are seeking answers to the violence that has sparked protests in cities and highlighted the nation's persistent racial divide.
Five Dallas officers were killed last Thursday while standing guard as hundreds of people protested against the police killings of black men in Louisiana and Minnesota earlier in the week.
"It's hard not to think sometimes that the centre might not hold, that things might get worse," Obama said. "We must reject such despair."
He joined politicians, police officers and families of the fallen at the service.
"The soul of our city was pierced," Dallas mayor Mike Rawlings said, as he welcomed Obama to the memorial service. The group had assembled to combat "a common disease" of violence, and honour those who fight it, "our men and women in blue, our peacemakers in blue".
Rawlings spoke close to five empty chairs and five portraits of the dead officers.
A call for national solidarity was reinforced by several speakers at the interfaith service, including former president George W Bush, a Dallas resident, who attended with his wife, Laura.
"At times it feels like the forces pulling us apart are stronger than the forces binding us together," Bush said.
"Too often we judge other groups by their worst examples, while judging ourselves by our best intentions. And this has strained our bonds of understanding and common purpose."
Bush called on Americans to reject the unity of grief and fear.
"We want the unity of hope, affection and higher purpose," he said.
Obama has denounced the shooting as a "vicious, calculated and despicable attack on law enforcement" by a "demented" individual. And he has argued that, despite the heated public outcry of the past week, the country is not as divided as it may seem.
Obama's choice of travelling companions underscored the theme. Republican senator Ted Cruz of Texas and House Democratic leader Nancy Pelosi of California joined Obama on Air Force One for the flight to Dallas. Republican senator John Cornyn, attended and spoke at the service, but did not travel with the president.
He described the attack as deeply personal.
"Being a Texan doesn't describe where you're from, it describes who your family is," the senator said.
The White House said the president worked late into the night writing his speech and consulting scripture for inspiration.
Just a few weeks ago, Obama spent hours in Orlando, Florida, consoling the loved ones of 49 people who were killed in a shooting rampage at a nightclub.
The Dallas attack ended when the gunman, Micah Johnson, 25, was killed by a bomb delivered by a police robot. The black army veteran portrayed his attack on the officers as payback for the fatal police shootings of black men in Baton Rouge, Louisiana, and suburban Minneapolis.
Portions of both shootings were videotaped and broadcast nationwide, leading to fresh outrage, protests and scores of arrests. The killings also put the country on edge, heightened racial tensions and pushed the issue of the use of deadly force against black males by white police to the forefront.
Obama sought to begin bridging those issues with his tribute to the fallen five, who included a former army ranger, a navy veteran and a newlywed starting a second family.