President Barack Obama sang “Amazing Grace” while paying 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.
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.