(CNN) President Barack Obama on Tuesday emotionally hailed the bravery of America's police forces at a memorial for five officers gunned down in Dallas, but warned the despair of minority communities who see the criminal justice system weighted against them must not be ignored.

In a soaring address, Obama said that a week of violence and racial tension had exposed the deepest fault lines in American democracy and acknowledged that the events of a traumatic week left the nation shocked and fearful. But ultimately, after one of the most searching discourses on race of his presidency, he concluded that the country's divides were not as acute as they often seemed.

"I know that Americans are struggling right, now," Obama said at an interfaith service in Dallas, also attended by former President George W. Bush, who lives in the city.

Yet he struck the consistent theme of his political career since bursting onto the scene at the 2004 Democratic National Convention: that Americans can bend the curve of history toward justice.

"We are not as divided as we seem. I know that because I know America," Obama said, adding that the way the residents of Dallas of all races came together after the tragedy that unfolded last week proved his point.

Rhetorical balancing act

The visit to Dallas required a rhetorical balancing act from the nation's first African-American president. Graphic cell phone video of the killings of several black men by police officers has provoked new racial questions for Obama as his historic presidency enters its final months. But he has also been accused by political opponents of showing insufficient support for police officers who operate in often perilous conditions.

Obama went out of his way to stress that "the overwhelming majority of police officers do an incredibly hard and dangerous job fairly and professionally. They are deserving of our respect and not our scorn." He also eulogized each of the dead Dallas police officers individually and pointed out that they had perished while protecting a rally called to protest police actions and praised them for upholding the constitutional rights.

But he also gave voice to the grievances of those who believe they are mistreated by police.

"When African-Americans from all walks of life, from different communities across the country voice a growing despair at what they perceive to be unequal treatment ... we cannot simply turn away and dismiss those in peaceful protest as trouble makers or paranoid," he said. "We can't simply dismiss this as a symptom of political correctness or reverse racism. To have your experience denied like that, dismissed by those in authority, ... it hurts."

Obama noted that despite the passage of civil rights legislation in the 1960's and an improvement in race relations over his lifetime, bias endures.

"We know it whether you are black or white or Hispanic or Asian or native American or of Middle Eastern descent we have all seen this bigotry in our own lives at some point," he said. "We have heard it at times in our own homes. If we are honest, perhaps we have heard prejudice in our own heads, felt it in our own hearts."

He added: "None of us are entirely innocent. No institution is entirely immune. We know this."

11th cities

It was not the first time Obama had been called upon to shoulder the grief and confusion of his nation: he has now delivered speeches after tragedies and gun massacres in 11 cities since taking office in 2009. At times on Tuesday, he seemed to be fighting against his own sense of impotence and disappointment that his rhetoric had not forged more progress.

"I've seen how inadequate words can be in bringing about lasting change. I've seen how inadequate my own words have been," Obama said.

In paying tribute to the police, Obama said that officers in Dallas and around the country had embraced a profession that came with risks like no other.

"From the moment you put on that uniform, you have answered a call that at any moment, even in the briefest interaction, may put your life in harm's way," Obama said.

At several points of his address, the President made a clear choice not to confront the politics or race and unrest head on -- accusing political leaders of allowing the conditions that lead to violence to build up, despite the possibility that his comments could anger opponents and even some people in the crowd in Dallas.

"As a society, we chose to under-invest in decent schools," he said. "We allow poverty to fester so that entire neighborhoods offer no prospect for gainful employment. We refuse to fund drug treatment and mental health programs."

And in a state where gun laws are among the most permissive in the U.S., the President issued an oblique call for reforms of firearms laws -- an issue that is guaranteed to stoke political controversy and which he has failed to make meaningful progress while in the White House.

"We flood communities with so many guns that it is easier for a teenager to buy a Glock than to get his hands on a computer or even a book. And then we tell the police, you are a social worker. You are a parent You are a teacher. You are a drug counselor. We tell them to keep those neighborhoods in check at any cost."

Obama's predecessor, Bush, also sought to bring Americans together after a week of tragedy.

"At our best, we know we have one country, one future, one destiny. 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," Bush said in a short speech.