"We still don't know all the facts. What we do know is that there has been a vicious, calculated and despicable attack on law enforcement," Obama told a press conference at a NATO summit in Warsaw.
"Police in Dallas were on duty doing their jobs keeping people safe during peaceful protests... we are praying for their recovery."
Five Dallas police officers killed at protest over shootings
Obama added that the officers were "targeted" by several suspects in the "tremendous tragedy."
"According to police, there are multiple suspects. We will learn more undoubtedly about their twisted motivations," he said.
"Let's be clear. There is no possible justification for these kinds of attacks or any violence against law enforcement.
"Anyone involved in the senseless murders will be held fully accountable. Justice will be done."
Obama said the killings once again raised the issue of gun control in the United States after a string of mass shootings.
"We also know when people are armed with powerful weapons, unfortunately, it makes attacks like these more deadly and more tragic," he said.
US woman livestreams boyfriend's dying moments after police shooting
"In the days ahead, we will have to consider those realities as well. In the meantime, today, our focus is on the victims and their families."
Several hundred people attended the Dallas rally, which ended just before the shots rang out around 9:00 pm (0200 GMT Friday).
The protest was one of several nationwide over the fatal police shootings of black men in Minnesota and Louisiana this week.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ