President Barack Obama has paid tribute to the victims of the Charleston shooting, saying the US has been blind to the “mayhem” caused by gun violence.
Mr Obama ended his eulogy for the Reverend Clementa Pinckney, singing Amazing Grace and reading out the names of the nine victims.
“What a life Clementa Pinckney lived,” Mr Obama said. “What an example he set. What a model for his faith.”
Thousands were in attendance at the South Carolina funeral.
Mr Obama said the attacks have called the US into action and the country cannot slip into a “comfortable silence” about racism, guns and other problems again.
Last week’s attack on a bible study group at a historic African-American church is thought to be racially motivated.
The tragedy has reignited debate about race relations and sparked a backlash against the Confederate battle flag.
At the scene – Nick Bryant,
None of America’s previous 43 presidents could have delivered this kind of eulogy, which sounded in parts like a sermon, in others like a state-of-the-union address and, at the end, a salvation meeting where, extraordinarily, he broke into song – Amazing Grace.
Often Barack Obama has been reticent to talk about America’s racial dilemma. He has never wanted to be typecast as its first black president.
But here, in one of the most memorable speeches of his presidency, it sounded like he was almost ventriloquizing the Reverend Dr Martin Luther King. This was perhaps his most expansive elucidation of the race issue to date.
Carrying out a kind of national audit, he spoke powerfully of the legacy of slavery and segregation and dealt with the unfinished business of the civil rights movement: a criminal justice system that often appears to unfairly punish blacks, racial discrimination in the workplace, poverty, education, and voting rights which once more seem at peril.
This was Barack Obama as the preacher president.
Dylann Roof, the 21-year-old suspected gunman in custody, has been photographed holding the flag.
Mr Obama said a flag did not cause the murders, but the country was ignoring the pain it caused.
The president was accompanied in Charleston by First Lady Michelle Obama, Vice-President Joe Biden and his wife Jill.
Former secretary of state and 2016 presidential candidate Hillary Clinton was in attendance as well.
Mr Obama delivered lengthy remarks, garnering applause and cries from the audience as he spoke in a preaching, rousing style.
“[Clementa] understood that justice grows out of recognition of ourselves in each other,” Mr Obama said. “My liberty depends on you being free too.”
In making a moral choice to change the tide of gun violence, the US will express God’s grace, he said.
He touched on the way racial bias effects how young black people get jobs, go to school and vote.
Addressing the families of the victims, Mr Obama said the nations shares in their grief.
“Our pain cuts that much deeper because it happened in a church,” he said.
The alleged killer Dylann Roof was “blinded by hatred” and could not see the grace of the churchgoers, who welcomed him openly into their prayer circle.
“The alleged killer could not imagine how the city of Charleston and the US would respond, with revulsion at his evil act,” Mr Obama said.
The first two funerals, for Ethel Lance and Sharonda Coleman-Singleton, were held on Thursday.
South Carolina Governor Nikki Haley, Charleston Mayor Joe Riley, the Reverend Jesse Jackson and the Reverend Al Sharpton were in attendance.