DALLAS (Reuters) - They stood in a line, clasping hands as a choir sang, Democrat and Republican, black and white, politician and cop. Led by President Barack Obama and his predecessor George W. Bush, they honored the five Dallas policemen slain last week and urged Americans to rise above racial divides and reject despair.

The scene unfolded at a memorial service after a week when Americans were jarred by video images of angry crowds protesting police killings of black men in Louisiana and Minnesota and heard the screams of Thursday’s sniper attack on police in Dallas by a black former U.S. soldier who had said he wanted to “kill white people.”

“We turn on the TV or surf the internet, and we can watch positions harden and lines drawn and people retreat to their respective corners,” the first black U.S. president said. “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.”

In a spontaneous display of unity, Obama and first lady Michelle Obama, former president George W. Bush and his wife Laura, Vice President Joe Biden and his wife Jill, Mayor Mike Rawlings, Police Chief David Brown and others on stage joined hands at the end of the service as a choir sang “The Battle Hymn of the Republic.”

Obama sought a careful balance, paying tribute to the dead police officers and showing respect for the country’s law enforcement while also acknowledging the concerns of those protesting against police violence.

He noted that the Dallas attack came during a protest against racial discrimination in policing that followed the fatal police shootings of black men in Baton Rouge, Louisiana, and outside St. Paul, Minnesota. A series of high-profile police killings of black men in the past two years have sparked the most intense debate on race and justice in America in decades.

“America, we know that bias remains. We know it,” Obama told the crowd of several hundred people, including many uniformed police officers, at the Morton H. Meyerson Symphony Center. “None of us is entirely innocent. No institution is entirely immune. And this includes our police departments.”

Slideshow ( 20 images )

BLACK LIVES MATTER

Obama alluded to the Black Lives Matter protest movement stirred into action by the long series of police killings, which some have painted as anti-police. He said that even people who dislike the phrase Black Lives Matter should recognize the pain felt by the family of Alton Sterling, the 37-year-old black man shot dead last week in Baton Rouge by police who said he was reaching for a gun.

Obama praised the police in Dallas and around the country.

“When anyone, no matter how good their intentions may be, paints all police as biased or bigoted, we undermine those officers we depend on for our safety,” Obama said.

“And as for those who use rhetoric suggesting harm to police, even if they don’t act on it themselves, well they not only make the jobs of police officers even more dangerous, but they do a disservice to the very cause of justice that they claim to promote,” Obama added.

Bush also addressed the packed hall, where five chairs were empty of people, holding folded American flags, in memory of the slain officers. Bush also sought to strike a note of unity.

Slideshow ( 20 images )

“At times it feels like the forces pulling us apart are stronger than the forces binding us together. Argument turns too easily into animosity,” Bush said. “We do not want the unity of grief nor do we want the unity of fear. We want the unity of hope, affection and high purpose.”

The slain officers were Mike Smith, 55; Lorne Ahrens, 48; Michael Krol, 40; Brent Thomson, 43, and Patrick Zamarripa, 32.

The death toll in Dallas was the highest for law enforcement on a single day in the United States since the Sept. 11, 2001, attacks. Nine other officers and two civilians were also wounded.

Outside the hall, Sharice Williams, 41, who drove roughly 95 miles (155 km) from Waco, stood in hopes of catching a glimpse of Obama.

“My heart is heavy. I’m tired of seeing my brothers and sisters killed, but the police don’t deserve that,” said Williams, who is black. “I’m praying that Obama being here brings us some kind of peace.”

Chief Warren Asmus, a 35-year veteran with the Los Angeles County Sheriff’s Department, said he flew in for the memorial.

“I was grateful for many of the things President Obama said in there,” said Asmus, 57. “I need to understand what the black community goes through just as much as they need to understand what the police community goes through.”

During his flight to Dallas, Obama placed condolence calls to families of Sterling and of Philando Castile, the 32-year-old man shot dead during a traffic stop outside St. Paul.