DALLAS — President Obama asked the nation to confront its deep divide on race at a memorial service Tuesday for the five police officers slain in a racially motivated sniper attack. 

Obama sought at times to reassure the nation, arguing it is not as divided as it has appeared to be in a week that included the killings in Dallas and separate shootings of black men by police in Louisiana and Minnesota.

“I know that because I know America. I know how far we have come against impossible odds,” Obama said in a speech at a packed Morton H. Meyerson Symphony Center.

“I know we’ll make it because of what I’ve experienced in my own life,” Obama added to an audience of mourners that included first lady Michelle ObamaMichelle LeVaughn Robinson ObamaObama on social media: You’ve got to ‘think before you tweet’ MSNBC trolls Trump with video montage of Obama saying ‘Merry Christmas’ Overnight Regulation: USDA delays healthy school lunch requirements | Senate panel advances controversial environmental pick | Drone industry pushes to ease rules | Dem commish joins energy regulator MORE, Vice President Biden, former President George W. Bush and former first lady Laura Bush.

Obama urged Americans to reject the notion that the violence that swept the country last week shows it is hopelessly divided.

More pointedly, he asked the nation to confront bigotry, which the nation’s first black president said remained pervasive throughout the country.

While race relations “have improved dramatically in my lifetime” and “those who deny it are dishonoring the struggles that helped us achieve that progress,” Obama said, “we know that bias remains.”

“None of us is entirely innocent,” he said to an audience filled with uniformed law enforcement officers donned in shawls to memorialize fallen colleagues. “No institution is entirely immune. Including our police departments.

“Even those who dislike the phrase ‘Black Lives Matter,’ surely we should be able to feel the pain of Alton Sterling’s family,” Obama said, referring to a black man shot to death by police in Baton Rouge, La. 

“We cannot simply turn away and dismiss those in peaceful protests as troublemakers,” he said. “We can’t simply dismiss it as a symptom of political correctness or reverse racism.”

Some of the president’s comments received just a smattering of applause from the crowd at the memorial.

But Obama earned a thunderous ovation when he said, as a country, “We ask the police to do too much, and we ask too little of ourselves.”

He lamented the lack of investment in inner-city schools and an absence of good mentoring at home. All of those problems, Obama said, contribute to the cycle of violence. 

Obama noted that he has repeatedly given speeches at memorials to victims of violence.

MSNBC reported it was the 15th time in his presidency that he has addressed the nation about a shooting with multiple victims.

His appearance in Dallas drew comparisons to his address last year at the funeral for the Rev. Clementa Pinckney, one of nine people killed at a historically African-American church in Charleston, S.C., by a shooter who allegedly wanted to start a race war.

The sniper who killed the five police officers in Dallas told police before he was killed that he targeted white people and white officers in his attack.

Obama acknowledged the limits of his words to help ­heal those wounds, choking up twice as he recalled all of the memorial services for victims of mass violence he has attended during his tenure. 

“I have seen how inadequate my own words have been,” the president said. So instead he quoted the Gospel of John, calling on Americans to “let us love not with words or speech, but with actions and with truth.”

Obama acknowledged that the attack — carried out by a black military veteran — has caused Americans to question whether the country’s racial wounds could ever be healed. 

He called the killings of police an “act not just of demented violence but of racial hatred,” adding, “It’s as if the deepest fault lines of our democracy have been exposed, perhaps even widened.” 

Obama said finding a solution isn’t so much a question of policy prescriptions but about “forging consensus and fighting cynicism and finding the will to make change.”

Obama and other political leaders have spoken about the need to unify in the wake of the violence, and the president invited one of his greatest political foes, Sen. Ted CruzRafael (Ted) Edward CruzDebbie Wasserman Schultz marks 10 years as breast cancer survivor Foreign agent registration is no magical shield against Russian propaganda Let Trump be Trump and he'll sail through 2020 MORE (R-Texas), to fly with him on Air Force One.

“At a time when our country is so divided, I think it is important that the country’s leaders are coming together across party lines, despite significant political differences, to emphasize a shared desire to unify the country,” White House press secretary Josh Earnest told reporters aboard Air Force One. 

George Bush, making a rare public speaking appearance in his hometown, spoke before Obama, saying, “At times, it seems like the forces pulling us apart are stronger than the forces holding us together. 

“Too often, we judge others by the worst examples, while judging ourselves by our best intentions,” he added.

But Bush expressed hope that if citizens channel their inner empathy, it would serve as “the bridge across our nation’s deepest divisions.” 

Obama later echoed Bush’s sentiments when he called on Americans to have an “open heart” and look past one another’s divisions. 

One of the most poignant moments of the service came at the end, when the dignitaries on stage joined hands and sang along with a chorus, which performed “The Battle Hymn of the Republic.” 

Obama also showered the Dallas Police Department with praise, saying it had adopted many of the reforms recommended by a White House task force last year. 

And he held up Dallas Mayor Mike Rawlings, a white man, and police Chief David Brown, a black man, as an example of leaders who, despite their “different backgrounds,” worked “together to unify a city, with strength and grace and wisdom.” 

But he also shared a moment of levity with Brown, who quoted Stevie Wonder’s song “As” in his introductory remarks. 

“I’m so glad I met Michelle first, because she loves Stevie Wonder,” he said, drawing laughter from the audience. 

Harper Neidig contributed.

Updated at 8:15 pm.