In an earlier written statement, Obama said that the ambush was "the work of cowards who speak for no one."
The Morning Rundown
Get a head start on the morning's top stories.
Hours later, he delivered remarks on the killings from the White House.
"The death of these three brave officers underscores the danger that police across the country confront every single day," Obama said. "We as a nation have to be loud and clear that nothing justifies violence against law enforcement. Attacks on police are an attack on all of us and the rule of law that makes society possible."
Obama said he had spoken with Louisiana Gov. John Bel Edwards and Baton Rouge Mayor Kip Holden to offer them the support of the federal government and to reiterate support for law enforcement.
The president said he had contacted Attorney General Loretta Lynch and that the FBI was on the scene with all levels of government to ensure that "justice will be done."
The president then offered prayers for the families of the fallen and wounded officers.
"This has happened far too often," Obama said as he referred to meetings he held with law enforcement in the wake of the Dallas ambush. "I'm surrounded by the best of the best every single day."
Obama called for "words and actions that can unite this country rather than divide it further" in light of political division.
"We don't need inflammatory rhetoric," Obama said. "We don't need careless accusations thrown around to score political points or to advance an agenda. We need to temper our words and open our hearts, all of us."