Media playback is unsupported on your device Media caption Obama reflects on role as 'consoler-in-chief' during Dallas speech

President Barack Obama has urged the US to "reject despair" as he paid tribute to five police officers killed by a gunman in Dallas.

He told a memorial service in the city the US must "try to find some meaning amidst our sorrow" and could unite.

His trip came amid mounting racial tensions across the country.

Micah Johnson killed the Dallas officers at a protest held over the recent police shootings of African-Americans in Minnesota and Louisiana.

Before he was killed by police, he said he was angry about the shootings.

Meanwhile, protests over excessive police force against black 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 were struggling with what had 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."

He honoured the bravery of police officers and said fewer people were being mourned at the service because of the courage of the officers killed.

Dallas police chief scarred by tragedy

Who were the victims?

US police: 'We are not punching bags'

US racial divide - special report

The service featured five portraits of the officers and five empty chairs.

Ex-President George W Bush, a former Texas governor, praised the police: "Their courage is our protection and shield."

And Dallas Mayor Mike Rawlings, who spoke first, said: "The soul of our city was pierced."

First Lady Michelle Obama, Vice President Joe Biden and his wife, Jill, will also hold a private meeting with the families of the victims on Wednesday.

Image copyright AP Image caption Pictures of the five fallen officers were central to the service

Image copyright European photopress agency Image caption Police Chief David Brown received a standing ovation when he was introduced

Image copyright AFP Image caption George W Bush praised the courage of the police

Image copyright EPA Image caption The city held a candlelight vigil to remember the slain officers

The US has been on edge in the wake of the recent string of violence, roiled by protests over police reform and race relations.

And Mr Obama has been criticised for not doing enough to support the police, many of whom say they feel under attack because of the protests and criticism.

Reaction to President Obama's speech

Nicholas Kristof of the New York Times called the speech "excellent" and that Mr Obama is "so eloquent on race"

Conservative talk radio host Dana Loesch said it was good until it became "a partisan political lecture on gun control, race, and policing"

Domenico Montanaro of NPR News called it the biggest race speech of Mr Obama's presidency

Conservative political operative Tim Miller said Mr Obama and George Bush's speeches had "hope, dignity and constructiveness"

Mr Obama and Mr Biden on Monday met 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.

Media playback is unsupported on your device Media caption President Obama: "I believe our sorrow can make us a better country"