DALLAS - Presidents Barack Obama and George W. Bush were among the many who attended and spoke at a memorial service for five police officers killed in a sniper attack in Dallas, Texas.

President Obama offered perhaps his strongest words yet of support for law enforcement, praising the dead as heroes who died while preserving a constitutional right.

"Like police officers across the country, these men and their families shared a commitment to something larger than themselves," Obama said.

He spoke before an audience that included police officers, relatives of the slain -- and five empty seats, each representing a fallen officer. A folded flag and a police hat rested on each chair. The president mentioned the slain officers by name and offered a few personal tidbits about each one.

Calling the attack the act of a "demented" man," Obama appealed for Americans to find a way to bridge the divide, noting that black communities often feel maligned and police officers feel underappreciated.

"I understand how Americans are feeling. But Dallas, I'm here to say we must reject such despair. I'm here to insist that we are not as divided as we seem," Obama said before launching into a defense of police and the sacrifices they make.

"We mourn fewer people today because of your brave actions," he said pointing at the audience filled with officers.

Dallas Police Chief David Brown and Dallas Mayor Mike Rawlings also spoke at the service. Both men have been praised for the way they have handled the aftermath of the tragedy.

The Associated Press wire services contributed to this report.