Charleston, South Carolina CNN  — 

President Barack Obama delivered a touching eulogy, a rousing political speech and a thoughtful meditation on race in America when he traveled to Charleston, South Carolina on Friday to speak at the funeral of the Rev. Clementa Pinckney, who was gunned down last week by a racist terrorist during Bible study.

But the President’s speech will be remembered for a moment at the end when he launched into a solo of “Amazing Grace,” that at first stunned the mourners and then brought them to their feet as they joined him in song.

“As a nation, out of this terrible tragedy, God has visited grace upon us for he has allowed us to see where we’ve been blind,” Obama said. “He’s given us the chance, where we’ve been lost, to find our best selves.”

RELATED: Best week in Washington: Obama’s legacy

The President’s remarks at times felt like a sermon, with organ chords backing him during some of the most impassioned passages. The mostly African-American crowd was, at the end of the eulogy, on its feet, clapping and cheering Obama as he named each victim of the church shooting and declaring each “had grace.”

The President, first lady Michelle Obama, Vice President Joe Biden, a bipartisan host of high-level members of Congress and Hillary Clinton all attended the memorial service at TD Arena in downtown Charleston. Last Wednesday, a 21-year-old man opened fire at a Bible study inside Charleston’s Emanuel African Methodist Episcopal Church, killing nine.

The shooter declared he was there to “kill black people,” and an online manifesto attributed to him contained white supremacist screeds.

Obama, in his eulogy, said the killer likely assumed he “would deepen divisions that trace back to our nation’s original sin.”

“But God works in mysterious ways,” Obama said. “God had different ideas. He didn’t know he was being used by God.”

“The alleged killer could have never anticipated the way the families of the fallen would respond when they saw him in court in the midst of unspeakable grief, with words of forgiveness,” Obama said.

The country, he argued, has responded to the church shooting “with a thoughtful introspection and self-examination that we so rarely see in public life.”

Friday’s funeral service for Pinckney wasn’t the first time Obama delivered a high-profile eulogy, and with a year and a half remaining in office, it may not be the last.

Read the President’s eulogy for Rev. Clementa Pinckney

But on Friday, Obama’s speech moved beyond just grief for the victims – the President stepped directly into a national conversation about race in which he plays a central role.

He declared the Confederate flag a symbol of racial oppression, and praised the renewed urgency in removing it from the South Carolina State Capitol.

“Removing the flag from this state’s capital would not be an act of political correctness,” he said. “It would not an insult to the valor of Confederate soldiers. It would simply be acknowledgment that the cause for which they fought, the cause of slavery, was wrong.”

Unlike past times Obama has confronted an act of violence, he knew the highest profile victim of the Charleston shooting personally. Obama met Pinckney as an early supporter of his 2008 presidential bid.

That personal connection differentiated Friday’s eulogy from the funerals Obama keynoted after previous shootings. So, too, did the renewed questions on race spurred by the shooter’s apparent motivations.

“None of us can or should expect a transformation in race relations overnight. Every time something like this happens, somebody says, ‘We have to have a conversation about race,’” Obama said. “We talk a lot about race. There’s no shortcut. We don’t need more talk.”

Prior to the eulogy, Obama himself used some of his bluntest language to date on race during an interview with comedian Marc Maron on Friday, saying that just because the N-word is no longer used frequently in public, “that’s not the measure of whether racism still exists or not.”

The moment was a distant cry from the earlier days of Obama’s presidency, when he studiously avoided discussing race or the implications of his election to office.

At Friday’s funeral, Obama called for greater attention to less apparent forms of racism.

“Maybe we now realize the way a racial bias can infect us even when we don’t realize it so that we’re guarding against not just racial slurs, but we’re also guarding against the subtle impulse to call Johnny back for a job interview but not Jamal,” he said.

Victims of the Charleston church shooting

CNN’s Carma Hassan contributed to this report.