President Barack Obama expressed Americans' horror and outrage over the targeted shootings of police officers, describing the fatal attack in Dallas as "despicable" and declaring there was no justification for the violence.

"I believe that I speak for every single American when I say that we are horrified over these events, and that we stand united with the people and the police department in Dallas," Mr Obama said.

He was speaking just hours after gunfire killed five officers and wounded seven others during protests over fatal police shootings of black men in Minnesota and Louisiana.

Mr Obama noted the facts were still coming to light but "what we do know is that there has been a vicious, calculated and despicable attack on law enforcement".

The president's message was delivered at long distance as he travelled overseas for talks with Nato and EU leaders.

Later, the White House announced he would cut his trip short by one day.

He will attend meetings in Warsaw on Saturday, as scheduled, before heading on to Spain, where his itinerary includes meetings with Spanish leaders and a visit to US troops.

He will now return to Washington on Sunday, and will visit Dallas at the request of Mayor Mike Rawlings early next week.

Combined with the recent massacre in Orlando, Florida, and the rise in so-called lone wolf terrorism, rising anxiety about public safety could mean the Dallas shooting has an enduring impact.

Mr Obama has aligned himself with civil rights protesters and others calling attention to racial disparities in the justice system, and he has been criticised from those who cast the movement as anti-law enforcement.

The debate has largely split along party lines and stands as a potentially potent issue in the presidential election.

Mr Obama tried to walk a delicate balance in his remarks.

Just hours before gunfire erupted in Dallas on Thursday, the president expressed solidarity with those outraged over police shootings in Baton Rouge and St Paul.

A visibly frustrated Mr Obama urged Americans to push for local law enforcement reforms and said all Americans, regardless of race, should care about the treatment of blacks and Hispanics by police.

Mr Obama argued there is no contradiction between supporting law enforcement and working to see that biases in the justice system are rooted out.

"So when people say 'Black Lives Matter,' that doesn't mean blue lives don't matter," he said, referring to police.

"It just means all lives matter - but right now, the big concern is the fact that the data shows black folks are more vulnerable to these kinds of incidents."

But the president also expressed his gratitude to police officers.

He returned to that theme after the Dallas shootings.

"Today is a wrenching reminder of the sacrifices that they make for us," he said.

"Today our focus is on the victims and their families. They are heartbroken. The entire city of Dallas is grieving. Police across America, which is a tight-knit family, feels this loss to their core."

Mr Obama ordered flags to be flown at half-mast in honour of the victims and he spoke by phone to Mr Rawlings, Dallas Police Chief David Brown and Attorney General Loretta Lynch.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.