ST. PAUL — President Obama, reacting with the same horror as many Americans to a grisly video of a bloody, dying man in Minnesota who was shot by the police, begged the nation to confront the racial disparities in law enforcement while acknowledging the dangers that officers face.

“When incidents like this occur, there’s a big chunk of our citizenry that feels as if, because of the color of their skin, they are not being treated the same, and that hurts, and that should trouble all of us,” Mr. Obama said in a statement on Thursday after arriving in Warsaw for a NATO summit. “This is not just a black issue, not just a Hispanic issue. This is an American issue that we all should care about.”

A few hours earlier, Gov. Mark Dayton of Minnesota, who seemed shaken by the video showing the man, Philando Castile, as he died, also pointed to the role of race. “Would this have happened if the driver were white, if the passengers were white?” he asked. “I don’t think it would have.”

The statements capped a wrenching day that started with widespread replays of the extraordinary video of Mr. Castile’s final moments and the aftermath of the shooting, which his girlfriend had narrated as they occurred live on Facebook. There were demonstrations and a vigil for Mr. Castile, with appearances by members of his family, in St. Paul.

But the shooting reverberated far beyond the state. In Dallas, gunfire broke out Thursday evening at a demonstration, turning a vocal but peaceful rally into chaos as two snipers shot at police officers, killing five of them, the police said.

Mr. Dayton and members of Minnesota’s congressional delegation asked for the Justice Department to investigate the death of Mr. Castile, 32, who died hours after the department took over the investigation into the fatal police shooting, also captured on video, in Baton Rouge, La. The governor said he had spoken with White House and Justice Department officials.