President Obama has called for restraint after three police officers were shot dead in the city of Baton Rouge in Louisiana, BBC News reports.
The gunman, Gavin Long, an African-American who had served for five years in the Marines, was also killed.
He had posted videos on the internet complaining about police treatment of African-Americans.
Tensions in Baton Rouge have been high since a black man Alton Sterling was shot dead by police two weeks ago.
That death – and a second police shooting in Minnesota – sparked protests across the United States and triggered a revenge attack by a black army veteran who shot dead five officers in the city of Dallas.
In one video, posted on YouTube, Long said that should “anything happen” to him, he was “not affiliated” with any group.
“I’m affiliated with the spirit of justice, nothing more nothing less. I thought my own thoughts, I made my own decisions,” he said.
In a live broadcast from the White House, President Obama called upon all Americans to unite and refrain from divisive language.
“Regardless of motive, the death of these three brave officers underscores the danger that police across the country confront every single day, and we as a nation have to be loud and clear that nothing justifies violence against law enforcement,” he said.
“Everyone right now focus on words and actions that can unite this country rather than divide it further,” he added, as the US begins two weeks of political conventions with Republicans meeting in Cleveland later on Monday, July 18.
“We need to temper our words and open our hearts… all of us,” said the president.
A vigil was attended by police officers and members of the public on Sunday evening at Saint John the Baptist Church in Zachary, just north of Baton Rouge.