WARSAW — President Obama, addressing the tumult, anger and confusion at home, said here Friday that he was outraged by the sniper attacks on the Dallas police that left five officers dead and seven wounded, calling the carnage "a vicious, calculated and despicable attack on law enforcement.”

Obama's remarks were brief, coming hours after the Dallas shootings and an earlier, emotional 16-minute speech that he delivered in response to the killings of black men by police in Falcon Heights, Minn., and Baton Rouge. The Dallas attacks took place during a protest rally over the police shootings in the other cities, which have prompted a national outcry and reignited debate over racial bias among law enforcement.

The president said there was "no possible justification" for the violence against police.

“We are horrified over these events and we stand united with the people and the police department in Dallas,” said Obama, who is in Poland for a NATO summit. He called the killings “senseless” and pledged that “justice will be done.”

Obama, appearing at a previously scheduled press briefing with two European leaders, said he would have more to say after additional information is learned about the shooters and their “twisted motives.” Three suspects are in custody, Dallas authorities said, and another is dead following a standoff with police.

The president’s remarks were carried live on cable news channels that had been airing blanket coverage of the Friday night attack. Obama emphasized that he had spoken by phone with Dallas Mayor Mike Rawlings and offered full federal assistance to the investigation. He added that the FBI has been in touch with local officials.

Aides said Obama was briefed by senior advisers. He appeared grim as he addressed reporters in the same small meeting room at a hotel here where he talked late Thursday about the killings in Minnesota and Louisiana that generated protests across the nation. In those remarks, Obama said he was “deeply troubled” by the deaths and called them “symptomatic” of a broader problem in the country.

After the Dallas shootings, Obama once again offered condolences to the families of the dead. He spoke generally of the need for reforms to America’s gun laws, which last month prompted sit-ins by Democratic lawmakers in the Congress demanding change.

“We also know when people are armed with powerful weapons, it makes events like these more deadly and more tragic, and we are going to have to consider those realities,” Obama said.

One of the most immediate questions for the president going forward will be whether he chooses to cancel the second leg of his European trip, a two-day visit to Spain, that is scheduled to begin Saturday evening and is packed with largely ceremonial visits. The cable news channels cut away from Obama's news briefing in Warsaw moments after he finished his remarks on the Dallas shootings, ignoring the rest of his remarks about the NATO summit.

The president's trip is likely to feel discordant to the American public at a time of renewed tensions between law enforcement officials and the communities they serve.

Obama’s impulse in the past — especially in response to major terrorist attacks in the United States or Europe — has been to stick to his planned business as much as possible. He resisted calls from Republicans to cut short his visit to Cuba this spring after the Islamic State terrorist attacks in Brussels. In 2014, following the beheading of journalist James Foley by Islamic State militants, Obama played golf, a move he later conceded was a mistake.

White House aides have said that canceling trips following terrorist attacks feeds the enemies’ narrative, makes them look more powerful and unnecessarily inflates the terrorist threat.

"I think everybody who knows me — including, I suspect, the press — understands that ... you take this stuff in. And it's serious business,” he said in an NBC interview in 2014. “And you care about it deeply."

The police shootings in Dallas and the events in Minnesota and Louisiana present a very different dynamic. The president has sought, in the wake of racially charged police shootings over the past several years, to balance support for police officers on the front lines with heightened federal scrutiny over the tactics they employ in the field. He established a federal commission to make policy recommendations after the unrest in Ferguson, Mo., following the police shooting of unarmed black teenager Michael Brown in 2014.

It has proved to be a tenuous balance, however, and the president at times has been accused by his political opponents of leaning too heavily against the police. Joe Walsh, a former one-term Republican congressman from Obama's home state of Illinois, blamed Obama for the violence in Dallas in a series of Twitter messages overnight.

At the same time, the Black Lives Matter protest movement focusing on police brutality has become a political force that has pushed the issue into the 2016 presidential campaign and disrupted events from the candidates vying to replace Obama next year.

Flying aboard Air Force One to Poland, Obama scrambled Thursday to respond to the shooting deaths of two black men in Louisiana and Minnesota that were broadcast on gruesome videos. He posted a message to Facebook saying that "all Americans should be deeply troubled" by the incidents, then he made impromptu remarks to reporters shortly after arriving in Warsaw.

He made clear that the country needed to focus more and move faster to curtail police violence against minorities. “This is not just a black issue. It's not just a Hispanic issue. This is an American issue that we should all care about,” Obama said Friday night, just hours before the Dallas police shootings. “All fair-minded people should be concerned.”

Cutting short his trip to Spain would signal the importance that he places on the issue.

Obama’s forceful critique of the racial inequities facing minorities in the criminal justice system could, in the wake of the Dallas killings, increase pressure on him to demonstrate more sympathy for the slain officers and their families.

“When people say 'black lives matter,' that doesn’t mean blue lives don’t matter,” Obama said during his remarks Thursday. “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.”

The shootings in Dallas, which came less than 10 hours later, seemed to underscore the dangers facing police. Police have “an extraordinarily difficult job and the vast majority of them do their job in an outstanding fashion," Obama said Friday. "Today is a wrenching reminder of the sacrifices they make for us."

Nakamura reported from Washington. Juliet Eilperin contributed to this report.